Author: Vasily Kuznetsov <[email protected]>
Branch: py3.3
Changeset: r72487:032296946827
Date: 2014-07-26 11:00 +0200
http://bitbucket.org/pypy/pypy/changeset/032296946827/

Log:    NoneType can be constructed.

diff --git a/pypy/module/__builtin__/test/test_construct_singletons.py 
b/pypy/module/__builtin__/test/test_construct_singletons.py
new file mode 100644
--- /dev/null
+++ b/pypy/module/__builtin__/test/test_construct_singletons.py
@@ -0,0 +1,7 @@
+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)
diff --git a/pypy/objspace/std/nonetype.py b/pypy/objspace/std/nonetype.py
--- a/pypy/objspace/std/nonetype.py
+++ b/pypy/objspace/std/nonetype.py
@@ -1,8 +1,15 @@
 from pypy.objspace.std.stdtypedef import StdTypeDef
+from pypy.interpreter import gateway
 
 
+def descr__new__(space, w_type):
+    return space.w_None
+
 # ____________________________________________________________
 
 none_typedef = StdTypeDef("NoneType",
+    __new__ = gateway.interp2app(descr__new__)
     )
 none_typedef.acceptable_as_base_class = False
+
+
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to