Commit 589e6a68 authored by Marius Wachtler's avatar Marius Wachtler

Ban creating instances of None

parent 5aabdb34
......@@ -3913,6 +3913,7 @@ void setupRuntime() {
none_cls->giveAttr("__nonzero__", new BoxedFunction(FunctionMetadata::create((void*)noneNonzero, BOXED_BOOL, 1)));
none_cls->giveAttr("__doc__", None);
none_cls->tp_hash = (hashfunc)_Py_HashPointer;
none_cls->tp_new = NULL; // don't allow creating instances
none_cls->freeze();
none_cls->tp_repr = none_repr;
......
print None.__class__
print type(None).__doc__, None.__doc__
try:
type(None)()
except TypeError as e:
print e
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment