[pypy-svn] r77910 - in pypy/branch/fast-forward: lib_pypy lib_pypy/ctypes_config_cache/test lib_pypy/pypy_test pypy/module/_md5 pypy/module/_sha

afa at codespeak.net afa at codespeak.net
Thu Oct 14 12:05:57 CEST 2010


Author: afa
Date: Thu Oct 14 12:05:55 2010
New Revision: 77910

Modified:
   pypy/branch/fast-forward/lib_pypy/_md5.py
   pypy/branch/fast-forward/lib_pypy/_sha.py
   pypy/branch/fast-forward/lib_pypy/ctypes_config_cache/test/test_cache.py
   pypy/branch/fast-forward/lib_pypy/pypy_test/test_md5_extra.py
   pypy/branch/fast-forward/lib_pypy/pypy_test/test_sha_extra.py
   pypy/branch/fast-forward/pypy/module/_md5/__init__.py
   pypy/branch/fast-forward/pypy/module/_md5/interp_md5.py
   pypy/branch/fast-forward/pypy/module/_sha/__init__.py
   pypy/branch/fast-forward/pypy/module/_sha/interp_sha.py
Log:
Line up md5 and sha modules with CPython.
Should fix a warning in hmac.py

+ fix tests after rename.


Modified: pypy/branch/fast-forward/lib_pypy/_md5.py
==============================================================================
--- pypy/branch/fast-forward/lib_pypy/_md5.py	(original)
+++ pypy/branch/fast-forward/lib_pypy/_md5.py	Thu Oct 14 12:05:55 2010
@@ -116,6 +116,7 @@
     "An implementation of the MD5 hash function in pure Python."
 
     digest_size = digestsize = 16
+    block_size = 64
 
     def __init__(self):
         "Initialisation."
@@ -369,24 +370,10 @@
 
 # ======================================================================
 # Mimic Python top-level functions from standard library API
-# for consistency with the md5 module of the standard library.
+# for consistency with the _md5 module of the standard library.
 # ======================================================================
 
-digest_size = digestsize = 16
-blocksize = 1
-
-def new(arg=None):
-    """Return a new md5 crypto object.
-
-    If arg is present, the method call update(arg) is made.
-    """
-
-    crypto = MD5Type()
-    if arg:
-        crypto.update(arg)
-
-    return crypto
-
+digest_size = 16
 
 def md5(arg=None):
     """Same as new().

Modified: pypy/branch/fast-forward/lib_pypy/_sha.py
==============================================================================
--- pypy/branch/fast-forward/lib_pypy/_sha.py	(original)
+++ pypy/branch/fast-forward/lib_pypy/_sha.py	Thu Oct 14 12:05:55 2010
@@ -118,6 +118,7 @@
     "An implementation of the MD5 hash function in pure Python."
 
     digest_size = digestsize = 20
+    block_size = 1
 
     def __init__(self):
         "Initialisation."
@@ -328,13 +329,14 @@
 
 # ======================================================================
 # Mimic Python top-level functions from standard library API
-# for consistency with the md5 module of the standard library.
+# for consistency with the _sha module of the standard library.
 # ======================================================================
 
 # These are mandatory variables in the module. They have constant values
 # in the SHA standard.
 
-digest_size = digestsize = 20
+digest_size = 20
+digestsize = 20
 blocksize = 1
 
 def new(arg=None):

Modified: pypy/branch/fast-forward/lib_pypy/ctypes_config_cache/test/test_cache.py
==============================================================================
--- pypy/branch/fast-forward/lib_pypy/ctypes_config_cache/test/test_cache.py	(original)
+++ pypy/branch/fast-forward/lib_pypy/ctypes_config_cache/test/test_cache.py	Thu Oct 14 12:05:55 2010
@@ -27,10 +27,6 @@
     d = run('syslog.ctc.py', '_syslog_cache.py')
     assert 'LOG_NOTICE' in d
 
-def test_hashlib():
-    d = run('hashlib.ctc.py', '_hashlib_cache.py')
-    assert hasattr(d['EVP_MD_CTX'], 'digest')
-
 def test_resource():
     d = run('resource.ctc.py', '_resource_cache.py')
     assert 'RLIM_NLIMITS' in d

Modified: pypy/branch/fast-forward/lib_pypy/pypy_test/test_md5_extra.py
==============================================================================
--- pypy/branch/fast-forward/lib_pypy/pypy_test/test_md5_extra.py	(original)
+++ pypy/branch/fast-forward/lib_pypy/pypy_test/test_md5_extra.py	Thu Oct 14 12:05:55 2010
@@ -6,7 +6,7 @@
 
 from __future__ import absolute_import
 import md5                              # CPython's implementation in C.
-from .. import md5 as pymd5  
+from .. import _md5 as pymd5  
 
 
 # Helpers...

Modified: pypy/branch/fast-forward/lib_pypy/pypy_test/test_sha_extra.py
==============================================================================
--- pypy/branch/fast-forward/lib_pypy/pypy_test/test_sha_extra.py	(original)
+++ pypy/branch/fast-forward/lib_pypy/pypy_test/test_sha_extra.py	Thu Oct 14 12:05:55 2010
@@ -4,7 +4,7 @@
 # Publication 180-1, Secure Hash Standard,  1995 April 17
 # http://www.itl.nist.gov/div897/pubs/fip180-1.htm
 from __future__ import absolute_import
-from .. import sha 
+from .. import _sha 
 
 class TestSHA: 
     def check(self, data, digest):

Modified: pypy/branch/fast-forward/pypy/module/_md5/__init__.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/_md5/__init__.py	(original)
+++ pypy/branch/fast-forward/pypy/module/_md5/__init__.py	Thu Oct 14 12:05:55 2010
@@ -19,12 +19,9 @@
 far using the digest() method."""
 
     interpleveldefs = {
-        'md5': 'interp_md5.W_MD5',
         'new': 'interp_md5.W_MD5',
         'MD5Type': 'interp_md5.W_MD5',
         'digest_size': 'space.wrap(16)',
-        'digestsize': 'space.wrap(16)',
-        'blocksize': 'space.wrap(1)',
         }
 
     appleveldefs = {

Modified: pypy/branch/fast-forward/pypy/module/_md5/interp_md5.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/_md5/interp_md5.py	(original)
+++ pypy/branch/fast-forward/pypy/module/_md5/interp_md5.py	Thu Oct 14 12:05:55 2010
@@ -49,6 +49,7 @@
     copy      = interp2app(W_MD5.copy_w, unwrap_spec=['self']),
     digest_size = 16,
     digestsize = 16,
+    block_size = 64,
     __doc__   = """md5(arg) -> return new md5 object.
 
 If arg is present, the method call update(arg) is made.""")

Modified: pypy/branch/fast-forward/pypy/module/_sha/__init__.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/_sha/__init__.py	(original)
+++ pypy/branch/fast-forward/pypy/module/_sha/__init__.py	Thu Oct 14 12:05:55 2010
@@ -19,7 +19,6 @@
 bits instead of MD5's 128 bits."""
 
     interpleveldefs = {
-        'sha': 'interp_sha.W_SHA',
         'new': 'interp_sha.W_SHA',
         'SHAType': 'interp_sha.W_SHA',
         'blocksize': 'space.wrap(1)',

Modified: pypy/branch/fast-forward/pypy/module/_sha/interp_sha.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/_sha/interp_sha.py	(original)
+++ pypy/branch/fast-forward/pypy/module/_sha/interp_sha.py	Thu Oct 14 12:05:55 2010
@@ -49,6 +49,7 @@
     copy      = interp2app(W_SHA.copy_w, unwrap_spec=['self']),
     digest_size = 20,
     digestsize = 20,
+    block_size = 64,
     __doc__   = """sha(arg) -> return new sha object.
 
 If arg is present, the method call update(arg) is made.""")



More information about the Pypy-commit mailing list