[pypy-svn] r77905 - in pypy/branch/fast-forward/pypy/module/_hashlib: . test

afa at codespeak.net afa at codespeak.net
Thu Oct 14 11:42:03 CEST 2010


Author: afa
Date: Thu Oct 14 11:42:02 2010
New Revision: 77905

Modified:
   pypy/branch/fast-forward/pypy/module/_hashlib/interp_hashlib.py
   pypy/branch/fast-forward/pypy/module/_hashlib/test/test_hashlib.py
Log:
Hash value was truncated to the first \0 :-(
Test and fix.


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	Thu Oct 14 11:42:02 2010
@@ -71,7 +71,7 @@
 
         try:
             ropenssl.EVP_DigestFinal(ctx, digest, None)
-            return rffi.charp2strn(digest, digest_size)
+            return rffi.charpsize2str(digest, digest_size)
         finally:
             lltype.free(digest, flavor='raw')
 

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	Thu Oct 14 11:42:02 2010
@@ -8,6 +8,7 @@
     def test_simple(self):
         import _hashlib
         assert isinstance(_hashlib.new('md5'), _hashlib.HASH)
+        assert len(_hashlib.new('md5').hexdigest()) == 32
 
     def test_attributes(self):
         import hashlib



More information about the Pypy-commit mailing list