set tp_new from the class in the hierarchy that actually owns the descriptor (closes #25731)
Debugging by Eryk Sun.
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index f5e4b02..a8206d3 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -4564,6 +4564,14 @@
self.assertRegex(repr(method),
r"<bound method qualname of <object object at .*>>")
+ 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):