(original) (raw)

changeset: 99977:a7953ee29f1c parent: 99974:2b0c7b67eca5 parent: 99975:3c9512d8ac0d user: Benjamin Peterson benjamin@python.org date: Mon Jan 18 21🔞35 2016 -0800 files: Lib/test/test_descr.py Misc/NEWS Objects/typeobject.c description: merge 3.5 (#25731) diff -r 2b0c7b67eca5 -r a7953ee29f1c Lib/test/test_descr.py --- a/Lib/test/test_descr.py Mon Jan 18 18:45:54 2016 -0800 +++ b/Lib/test/test_descr.py Mon Jan 18 21🔞35 2016 -0800 @@ -4564,6 +4564,14 @@ self.assertRegex(repr(method), r">") + def test_deleting_new_in_subclasses(self): + class X: + def __init__(self, a): + pass + X.__new__ = None + del X.__new__ + X(1) # should work + class DictProxyTests(unittest.TestCase): def setUp(self): diff -r 2b0c7b67eca5 -r a7953ee29f1c Misc/NEWS --- a/Misc/NEWS Mon Jan 18 18:45:54 2016 -0800 +++ b/Misc/NEWS Mon Jan 18 21🔞35 2016 -0800 @@ -13,6 +13,8 @@ - Issue #25791: Trying to resolve a relative import without __spec__ or __package__ defined now raises an ImportWarning +- Issue #25731: Fix set and deleting __new__ on a class. + - Issue #25961: Disallowed null characters in the type name. - Issue #25973: Fix segfault when an invalid nonlocal statement binds a name diff -r 2b0c7b67eca5 -r a7953ee29f1c Objects/typeobject.c --- a/Objects/typeobject.c Mon Jan 18 18:45:54 2016 -0800 +++ b/Objects/typeobject.c Mon Jan 18 21🔞35 2016 -0800 @@ -6791,7 +6791,7 @@ sanity checks and constructing a new argument list. Cut all that nonsense short -- this speeds up instance creation tremendously. */ - specific = (void *)type->tp_new; + specific = (void *)((PyTypeObject *)PyCFunction_GET_SELF(descr))->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/benjamin@python.org