[pypy-commit] pypy py3k: Merged.

prestontimmons noreply at buildbot.pypy.org
Wed Mar 14 19:34:37 CET 2012


Author: Preston Timmons <prestontimmons at gmail.com>
Branch: py3k
Changeset: r53566:9be592a78766
Date: 2012-03-13 02:55 +0000
http://bitbucket.org/pypy/pypy/changeset/9be592a78766/

Log:	Merged.

diff --git a/pypy/module/_hashlib/interp_hashlib.py b/pypy/module/_hashlib/interp_hashlib.py
--- a/pypy/module/_hashlib/interp_hashlib.py
+++ b/pypy/module/_hashlib/interp_hashlib.py
@@ -157,7 +157,6 @@
     hexdigest=interp2app(W_Hash.hexdigest),
     #
     digest_size=GetSetProperty(W_Hash.get_digest_size),
-    digestsize=GetSetProperty(W_Hash.get_digest_size),
     block_size=GetSetProperty(W_Hash.get_block_size),
     )
 W_Hash.acceptable_as_base_class = False
diff --git a/pypy/module/_hashlib/test/test_hashlib.py b/pypy/module/_hashlib/test/test_hashlib.py
--- a/pypy/module/_hashlib/test/test_hashlib.py
+++ b/pypy/module/_hashlib/test/test_hashlib.py
@@ -26,7 +26,6 @@
                                     }.items():
             h = hashlib.new(name)
             assert h.digest_size == expected_size
-            assert h.digestsize == expected_size
             #
             h.update(b'abc')
             h2 = h.copy()
@@ -42,25 +41,6 @@
             c_digest    = digest
             c_hexdigest = hexdigest
 
-            # also test the pure Python implementation
-            py_new = getattr(hashlib, '__get_builtin_constructor')
-            h = py_new(name)('')
-            assert h.digest_size == expected_size
-            assert h.digestsize == expected_size
-            #
-            h.update('abc')
-            h2 = h.copy()
-            h.update('def')
-            digest = h.digest()
-            hexdigest = h.hexdigest()
-            h2.update('d')
-            h2.update('ef')
-            assert digest    == h2.digest()
-            assert hexdigest == h2.hexdigest()
-
-            # compare both implementations
-            assert c_digest    == digest
-            assert c_hexdigest == hexdigest
 
     def test_shortcut(self):
         import hashlib
diff --git a/pypy/module/_md5/__init__.py b/pypy/module/_md5/__init__.py
deleted file mode 100644
--- a/pypy/module/_md5/__init__.py
+++ /dev/null
@@ -1,26 +0,0 @@
-
-"""
-Mixed-module definition for the md5 module.
-Note that there is also a pure Python implementation in pypy/lib/md5.py;
-the present mixed-module version of md5 takes precedence if it is enabled.
-"""
-
-from pypy.interpreter.mixedmodule import MixedModule
-
-
-class Module(MixedModule):
-    """\
-This module implements the interface to RSA's MD5 message digest
-algorithm (see also Internet RFC 1321). Its use is quite
-straightforward: use new() to create an md5 object. You can now feed
-this object with arbitrary strings using the update() method, and at any
-point you can ask it for the digest (a strong kind of 128-bit checksum,
-a.k.a. ``fingerprint'') of the concatenation of the strings fed to it so
-far using the digest() method."""
-
-    interpleveldefs = {
-        'md5': 'interp_md5.W_MD5',
-        }
-
-    appleveldefs = {
-        }
diff --git a/pypy/module/_md5/interp_md5.py b/pypy/module/_md5/interp_md5.py
deleted file mode 100644
--- a/pypy/module/_md5/interp_md5.py
+++ /dev/null
@@ -1,56 +0,0 @@
-from pypy.rlib import rmd5
-from pypy.interpreter.baseobjspace import Wrappable
-from pypy.interpreter.typedef import TypeDef
-from pypy.interpreter.gateway import interp2app, unwrap_spec
-
-
-class W_MD5(Wrappable, rmd5.RMD5):
-    """
-    A subclass of RMD5 that can be exposed to app-level.
-    """
-
-    def __init__(self, space):
-        self.space = space
-        self._init()
-
-    @unwrap_spec(string='bufferstr')
-    def update_w(self, string):
-        self.update(string)
-
-    def digest_w(self):
-        return self.space.wrapbytes(self.digest())
-
-    def hexdigest_w(self):
-        return self.space.wrap(self.hexdigest())
-
-    def copy_w(self):
-        clone = W_MD5(self.space)
-        clone._copyfrom(self)
-        return self.space.wrap(clone)
-
-
- at unwrap_spec(initialdata='bufferstr')
-def W_MD5___new__(space, w_subtype, initialdata=''):
-    """
-    Create a new md5 object and call its initializer.
-    """
-    w_md5 = space.allocate_instance(W_MD5, w_subtype)
-    md5 = space.interp_w(W_MD5, w_md5)
-    W_MD5.__init__(md5, space)
-    md5.update(initialdata)
-    return w_md5
-
-
-W_MD5.typedef = TypeDef(
-    'MD5Type',
-    __new__   = interp2app(W_MD5___new__),
-    update    = interp2app(W_MD5.update_w),
-    digest    = interp2app(W_MD5.digest_w),
-    hexdigest = interp2app(W_MD5.hexdigest_w),
-    copy      = interp2app(W_MD5.copy_w),
-    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.""")
diff --git a/pypy/module/_md5/test/test_md5.py b/pypy/module/_md5/test/test_md5.py
deleted file mode 100644
--- a/pypy/module/_md5/test/test_md5.py
+++ /dev/null
@@ -1,102 +0,0 @@
-"""
-Tests for the md5 module implemented at interp-level in pypy/module/_md5.
-"""
-
-import py, sys
-from pypy.conftest import gettestobjspace
-
-
-class AppTestMD5(object):
-
-    def setup_class(cls):
-        """
-        Create a space with the md5 module and import it for use by the
-        tests.
-        """
-        cls.space = gettestobjspace(usemodules=['_md5'])
-        cls.w_md5 = cls.space.appexec([], """():
-            import _md5
-            return _md5
-        """)
-
-
-    def test_digest_size(self):
-        """
-        md5.digest_size should be 16.
-        """
-        import sys
-        assert self.md5.md5().digest_size == 16
-        if sys.version_info >= (2, 5):
-            assert self.md5.blocksize == 1
-            assert self.md5.md5().digestsize == 16
-
-
-    def test_MD5Type(self):
-        """
-        Test the construction of an md5 object.
-        """
-        md5 = self.md5
-        d = md5.md5()
-
-
-    def test_md5object(self):
-        """
-        Feed example strings into a md5 object and check the digest and
-        hexdigest.
-        """
-        md5 = self.md5
-        import binascii
-        cases = (
-          (b"",
-           "d41d8cd98f00b204e9800998ecf8427e"),
-          (b"a",
-           "0cc175b9c0f1b6a831c399e269772661"),
-          (b"abc",
-           "900150983cd24fb0d6963f7d28e17f72"),
-          (b"message digest",
-           "f96b697d7cb7938d525a2f31aaf161d0"),
-          (b"abcdefghijklmnopqrstuvwxyz",
-           "c3fcd3d76192e4007dfb496cca67e13b"),
-          (b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
-           "d174ab98d277d9f5a5611c2c9f419d9f"),
-          (b"1234567890"*8,
-           "57edf4a22be3c955ac49da2e2107b67a"),
-        )
-        for input, expected in cases:
-            d = md5.md5(input)
-            assert d.hexdigest() == expected
-            assert d.digest() == binascii.unhexlify(expected.encode('ascii'))
-
-
-    def test_copy(self):
-        """
-        Test the copy() method.
-        """
-        md5 = self.md5
-        d1 = md5.md5()
-        d1.update(b"abcde")
-        d2 = d1.copy()
-        d2.update(b"fgh")
-        d1.update(b"jkl")
-        assert d1.hexdigest() == 'e570e7110ecef72fcb772a9c05d03373'
-        assert d2.hexdigest() == 'e8dc4081b13434b45189a720b77b6818'
-
-
-    def test_buffer(self):
-        """
-        Test passing a buffer object.
-        """
-        md5 = self.md5
-        d1 = md5.md5(buffer(b"abcde"))
-        d1.update(buffer(b"jkl"))
-        assert d1.hexdigest() == 'e570e7110ecef72fcb772a9c05d03373'
-
-
-    def test_unicode(self):
-        """
-        Test passing unicode strings.
-        """
-        md5 = self.md5
-        raises(TypeError, md5.md5, "abcde")
-        d1 = md5.md5()
-        raises(TypeError, d1.update, "jkl")
diff --git a/pypy/objspace/std/test/test_typeobject.py b/pypy/objspace/std/test/test_typeobject.py
--- a/pypy/objspace/std/test/test_typeobject.py
+++ b/pypy/objspace/std/test/test_typeobject.py
@@ -118,7 +118,7 @@
         C = type('C', (object,), {'x': lambda: 42})
         unbound_meth = C.x
         raises(TypeError, unbound_meth)
-        assert unbound_meth.im_func() == 42
+        assert unbound_meth.__func__() == 42
         raises(TypeError, type)
         raises(TypeError, type, 'test', (object,))
         raises(TypeError, type, 'test', (object,), {}, 42)
@@ -220,7 +220,7 @@
 
         try:
             D.__bases__ = ()
-        except TypeError, msg:
+        except TypeError as msg:
             if str(msg) == "a new-style class can't have only classic bases":
                 assert 0, "wrong error message for .__bases__ = ()"
         else:
@@ -278,7 +278,7 @@
                 return super(WorkOnce, self).__new__(WorkOnce, name, bases, ns)
             def mro(instance):
                 if instance.flag > 0:
-                    raise RuntimeError, "bozo"
+                    raise RuntimeError("bozo")
                 else:
                     instance.flag += 1
                     return type.mro(instance)
@@ -345,7 +345,7 @@
         except TypeError:
             pass
         else:
-            raise TestFailed, "didn't catch MRO conflict"
+            raise TestFailed("didn't catch MRO conflict")
 
     def test_mutable_bases_versus_nonheap_types(self):
         class A(int):
@@ -479,7 +479,7 @@
         except TypeError:
             pass
         else:
-            raise AssertionError, "this multiple inheritance should fail"
+            raise AssertionError("this multiple inheritance should fail")
 
     def test_outer_metaclass(self):
         class OuterMetaClass(type):
@@ -503,7 +503,7 @@
             pass
 
         g = {'__metaclass__': __metaclass__}
-        exec "class HasImplicitMetaclass: pass\n" in g
+        exec("class HasImplicitMetaclass: pass\n", g)
 
         HasImplicitMetaclass = g['HasImplicitMetaclass']
         assert type(HasImplicitMetaclass) == __metaclass__
@@ -549,7 +549,7 @@
         try:
             assert NoDoc.__doc__ == None
         except AttributeError:
-            raise AssertionError, "__doc__ missing!"
+            raise AssertionError("__doc__ missing!")
 
     def test_explicitdoc(self):
         class ExplicitDoc(object):
@@ -576,7 +576,7 @@
             #       we always raise AttributeError.
             pass
         else:
-            raise AssertionError, '__doc__ should not be writable'
+            raise AssertionError('__doc__ should not be writable')
 
         assert ImmutableDoc.__doc__ == 'foo'
 
@@ -693,7 +693,7 @@
             __slots__ = "abc"
 
         class B(object):
-            __slots__ = u"abc"
+            __slots__ = "abc"
 
         a = A()
         a.abc = "awesome"
@@ -980,12 +980,12 @@
 
     def test_module(self):
         def f(): pass
-        assert object.__module__ == '__builtin__'
-        assert int.__module__ == '__builtin__'
-        assert type.__module__ == '__builtin__'
-        assert type(f).__module__ == '__builtin__'
+        assert object.__module__ == 'builtins'
+        assert int.__module__ == 'builtins'
+        assert type.__module__ == 'builtins'
+        assert type(f).__module__ == 'builtins'
         d = {'__name__': 'yay'}
-        exec """class A(object):\n  pass\n""" in d
+        exec("""class A(object):\n  pass\n""", d)
         A = d['A']
         assert A.__module__ == 'yay'
 


More information about the pypy-commit mailing list