[pypy-commit] pypy py3.3: NoneType can be constructed.
kvas
noreply at buildbot.pypy.org
Sat Jul 26 11:04:11 CEST 2014
Author: Vasily Kuznetsov <kvas.it at gmail.com>
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
+
+
More information about the pypy-commit
mailing list