From 16401d5be8fba35599caedb4c78901d4b66ac082 Mon Sep 17 00:00:00 2001 From: Manish Kumar Date: Fri, 26 Aug 2016 12:52:51 +0530 Subject: fixed : Divide by zero error came when string was empty, also a test --- netlib/strutils.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'netlib/strutils.py') diff --git a/netlib/strutils.py b/netlib/strutils.py index 4a46b6b1..4cb3b805 100644 --- a/netlib/strutils.py +++ b/netlib/strutils.py @@ -121,6 +121,9 @@ def escaped_str_to_bytes(data): def is_mostly_bin(s): # type: (bytes) -> bool + if not s or len(s) == 0: + return False + return sum( i < 9 or 13 < i < 32 or 126 < i for i in six.iterbytes(s[:100]) -- cgit v1.2.3