diff options
author | Harel Ben-Attia <harelba@gmail.com> | 2020-09-14 16:05:22 +0300 |
---|---|---|
committer | Harel Ben-Attia <harelba@gmail.com> | 2020-09-14 16:05:22 +0300 |
commit | 865f591a10141f708710532d7b0f40ea4e2d1386 (patch) | |
tree | 0cee978962f60605fd29b82c82248c2e244fc5bb | |
parent | 5b428b60d63b50c17faf68a5969961a67bdd3467 (diff) |
make sha1 py2/py3 compatible2.0.17usability-additions
-rwxr-xr-x | bin/q.py | 4 |
1 files changed, 1 insertions, 3 deletions
@@ -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): |