Skip to content

Commit

Permalink
make sha1 py2/py3 compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
harelba committed Sep 14, 2020
1 parent 5b428b6 commit 865f591
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions bin/q.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,7 @@ def sha(data,algorithm,encoding):

# For backward compatibility only (doesn't handle encoding well enough)
def sha1(data):
if not isinstance(data,str) and not isinstance(data,unicode):
return hashlib.sha1(str(data)).hexdigest()
return hashlib.sha1(data).hexdigest()
return hashlib.sha1(six.text_type(data).encode('utf-8')).hexdigest()

# TODO Add caching of compiled regexps - Will be added after benchmarking capability is baked in
def regexp(regular_expression, data):
Expand Down

0 comments on commit 865f591

Please sign in to comment.