diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-10-08 21:08:48 +0300 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-10-08 21:08:48 +0300 |
commit | 9d67ec51a65af6408887041d8e841c1bf7d046b7 (patch) | |
tree | c3201ce7b6a3128cb8216a6e04ad208d4d9428d9 /Lib/hashlib.py | |
parent | c3a0b4fef5f33c776857fe336932d163cd56815d (diff) | |
parent | 3cf0676c2d969a7c795c3ccf152e2dd77008ee14 (diff) | |
download | cpython-9d67ec51a65af6408887041d8e841c1bf7d046b7.tar.gz |
Issue #18037: Do not escape '\u' and '\U' in raw strings.
Diffstat (limited to 'Lib/hashlib.py')
-rw-r--r-- | Lib/hashlib.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/Lib/hashlib.py b/Lib/hashlib.py index 21454c7d30..a1bd8b2de8 100644 --- a/Lib/hashlib.py +++ b/Lib/hashlib.py @@ -54,7 +54,8 @@ More condensed: # This tuple and __get_builtin_constructor() must be modified if a new # always available algorithm is added. -__always_supported = ('md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512') +__always_supported = ('md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512', + 'sha3_224', 'sha3_256', 'sha3_384', 'sha3_512') algorithms_guaranteed = set(__always_supported) algorithms_available = set(__always_supported) @@ -85,6 +86,18 @@ def __get_builtin_constructor(name): return _sha512.sha512 elif bs == '384': return _sha512.sha384 + elif name in {'sha3_224', 'sha3_256', 'sha3_384', 'sha3_512', + 'SHA3_224', 'SHA3_256', 'SHA3_384', 'SHA3_512'}: + import _sha3 + bs = name[5:] + if bs == '224': + return _sha3.sha3_224 + elif bs == '256': + return _sha3.sha3_256 + elif bs == '384': + return _sha3.sha3_384 + elif bs == '512': + return _sha3.sha3_512 except ImportError: pass # no extension module, this hash is unsupported. |