[pypy-commit] pypy py3.3: Fixed test_construct_singletons for Ellipsis and NotImplemented as well, so now ellipsis and NotImplementedType can be constructed.

kvas noreply at buildbot.pypy.org
Sat Jul 26 17:39:58 CEST 2014


Author: Vasily Kuznetsov <kvas.it at gmail.com>
Branch: py3.3
Changeset: r72534:1c542d770ddb
Date: 2014-07-26 16:25 +0200
http://bitbucket.org/pypy/pypy/changeset/1c542d770ddb/

Log:	Fixed test_construct_singletons for Ellipsis and NotImplemented as
	well, so now ellipsis and NotImplementedType can be constructed.

diff --git a/pypy/interpreter/typedef.py b/pypy/interpreter/typedef.py
--- a/pypy/interpreter/typedef.py
+++ b/pypy/interpreter/typedef.py
@@ -950,11 +950,13 @@
 Cell.typedef.acceptable_as_base_class = False
 
 Ellipsis.typedef = TypeDef("Ellipsis",
+    __new__ = interp2app(lambda space, w_type: space.w_Ellipsis),
     __repr__ = interp2app(Ellipsis.descr__repr__),
 )
 Ellipsis.typedef.acceptable_as_base_class = False
 
 NotImplemented.typedef = TypeDef("NotImplemented",
+    __new__ = interp2app(lambda space, w_type: space.w_NotImplemented),
     __repr__ = interp2app(NotImplemented.descr__repr__),
 )
 NotImplemented.typedef.acceptable_as_base_class = False
diff --git a/pypy/module/__builtin__/test/test_construct_singletons.py b/pypy/module/__builtin__/test/test_construct_singletons.py
--- a/pypy/module/__builtin__/test/test_construct_singletons.py
+++ b/pypy/module/__builtin__/test/test_construct_singletons.py
@@ -1,7 +1,8 @@
 class AppTestConstructSingletons:
 
     def test_construct_singletons(self):
-        none_type = type(None)
-        assert none_type() is None
-        raises(TypeError, none_type, 1, 2)
-        raises(TypeError, none_type, a=1, b=2)
+        for const in None, Ellipsis, NotImplemented:
+            const_type = type(const)
+            assert const_type() is const
+            raises(TypeError, const_type, 1, 2)
+            raises(TypeError, const_type, a=1, b=2)


More information about the pypy-commit mailing list