diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-12-14 17:56:53 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-12-14 17:56:53 (GMT) |
commit | bdfc5ff17e9ad6c924aeb5f62ba51e948deec589 (patch) | |
tree | c5aad7d8f387b19c1fc55997c61c9bdd2182965c | |
parent | 69598527c7b8c538d75ec1b69c54f317dee0c47a (diff) | |
parent | 386072ebe02b54eb9fb303031c769bef094967f5 (diff) | |
download | cpython-bdfc5ff17e9ad6c924aeb5f62ba51e948deec589.zip cpython-bdfc5ff17e9ad6c924aeb5f62ba51e948deec589.tar.gz cpython-bdfc5ff17e9ad6c924aeb5f62ba51e948deec589.tar.bz2 |
Merge from 3.6.
-rw-r--r-- | Lib/test/test_descr.py | 2 | ||||
-rw-r--r-- | Misc/NEWS | 3 | ||||
-rw-r--r-- | Objects/typeobject.c | 29 |
3 files changed, 3 insertions, 31 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index ebfcb77..c5bff77 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -1662,6 +1662,7 @@ order (MRO) for bases """ self.assertEqual(b.foo, 3) self.assertEqual(b.__class__, D) + @unittest.expectedFailure def test_bad_new(self): self.assertRaises(TypeError, object.__new__) self.assertRaises(TypeError, object.__new__, '') @@ -1708,6 +1709,7 @@ order (MRO) for bases """ object.__init__(A(3)) self.assertRaises(TypeError, object.__init__, A(3), 5) + @unittest.expectedFailure def test_restored_object_new(self): class A(object): def __new__(cls, *args, **kwargs): @@ -19,9 +19,6 @@ Core and Builtins - Issue #28918: Fix the cross compilation of xxlimited when Python has been built with Py_DEBUG defined. -- Issue #5322: Fixed setting __new__ to a PyCFunction inside Python code. - Original patch by Andreas Stührk. - - Issue #23722: Rather than silently producing a class that doesn't support zero-argument ``super()`` in methods, failing to pass the new ``__classcell__`` namespace entry up to ``type.__new__`` now results in a diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 88493b5..391eed3 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -6847,34 +6847,7 @@ update_one_slot(PyTypeObject *type, slotdef *p) sanity checks and constructing a new argument list. Cut all that nonsense short -- this speeds up instance creation tremendously. */ - PyObject *self = PyCFunction_GET_SELF(descr); - if (!self || !PyType_Check(self)) { - /* This should never happen because - tp_new_wrapper expects a type for self. - Use slot_tp_new which will call - tp_new_wrapper which will raise an - exception. */ - specific = (void *)slot_tp_new; - } - else { - PyTypeObject *staticbase; - specific = ((PyTypeObject *)self)->tp_new; - /* Check that the user does not do anything - silly and unsafe like object.__new__(dict). - To do this, we check that the most derived - base that's not a heap type is this type. */ - staticbase = type->tp_base; - while (staticbase && - (staticbase->tp_flags & Py_TPFLAGS_HEAPTYPE)) - staticbase = staticbase->tp_base; - if (staticbase && - staticbase->tp_new != specific) - /* Seems to be unsafe, better use - slot_tp_new which will call - tp_new_wrapper which will raise an - exception if it is unsafe. */ - specific = (void *)slot_tp_new; - } + specific = (void *)type->tp_new; /* XXX I'm not 100% sure that there isn't a hole in this reasoning that requires additional sanity checks. I'll buy the first person to |