[pypy-svn] r78639 - in pypy/branch/fast-forward/pypy/module/_hashlib: . test
afa at codespeak.net
afa at codespeak.net
Mon Nov 1 21:45:22 CET 2010
Author: afa
Date: Mon Nov 1 21:45:18 2010
New Revision: 78639
Modified:
pypy/branch/fast-forward/pypy/module/_hashlib/interp_hashlib.py
pypy/branch/fast-forward/pypy/module/_hashlib/test/test_hashlib.py
Log:
Fix hashlib module, when method name is given as uppercase.
Modified: pypy/branch/fast-forward/pypy/module/_hashlib/interp_hashlib.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/_hashlib/interp_hashlib.py (original)
+++ pypy/branch/fast-forward/pypy/module/_hashlib/interp_hashlib.py Mon Nov 1 21:45:18 2010
@@ -82,12 +82,12 @@
# XXX significantly harder to implement in another way.
# Values are digest sizes in bytes
return {
- 'md5': 16,
- 'sha1': 20,
- 'sha224': 28,
- 'sha256': 32,
- 'sha384': 48,
- 'sha512': 64,
+ 'md5': 16, 'MD5': 16,
+ 'sha1': 20, 'SHA1': 20,
+ 'sha224': 28, 'SHA224': 28,
+ 'sha256': 32, 'SHA256': 32,
+ 'sha384': 48, 'SHA384': 48,
+ 'sha512': 64, 'SHA512': 64,
}.get(self.name, 0)
def _block_size(self):
@@ -96,12 +96,12 @@
# XXX and would be significantly harder to implement in
# XXX another way.
return {
- 'md5': 64,
- 'sha1': 64,
- 'sha224': 64,
- 'sha256': 64,
- 'sha384': 128,
- 'sha512': 128,
+ 'md5': 64, 'MD5': 64,
+ 'sha1': 64, 'SHA1': 64,
+ 'sha224': 64, 'SHA224': 64,
+ 'sha256': 64, 'SHA256': 64,
+ 'sha384': 128, 'SHA384': 128,
+ 'sha512': 128, 'SHA512': 128,
}.get(self.name, 0)
W_Hash.typedef = TypeDef(
Modified: pypy/branch/fast-forward/pypy/module/_hashlib/test/test_hashlib.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/_hashlib/test/test_hashlib.py (original)
+++ pypy/branch/fast-forward/pypy/module/_hashlib/test/test_hashlib.py Mon Nov 1 21:45:18 2010
@@ -65,3 +65,9 @@
import _hashlib
assert _hashlib.new('sha1', u'xxx').__class__.__name__ == 'HASH'
+ def test_uppercase(self):
+ import _hashlib
+ h = _hashlib.new('MD5')
+ assert h.digest_size == 16
+ assert len(h.hexdigest()) == 32
+
More information about the Pypy-commit
mailing list