Skip to content

Commit f3a60a8

Browse files
committed
Drop cmp_to_key test and strong references to self, caller should keep
1 parent 0df9822 commit f3a60a8

2 files changed

Lines changed: 0 additions & 20 deletions

File tree

‎Lib/test/test_descr.py‎

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import builtins
22
import copyreg
3-
import functools
43
import gc
54
import itertools
65
import math
@@ -5204,22 +5203,6 @@ class Foo:
52045203
self.assertRaises(RecursionError, str, foo)
52055204
self.assertRaises(RecursionError, repr, foo)
52065205

5207-
def test_slot_wrapper_holds_self(self):
5208-
# Make sure wrapper takes a strong reference to itself when called.
5209-
# cmp_to_key() does not own the objects passed to it. Custom list type
5210-
# so we can take a weakref.
5211-
class L(list):
5212-
pass
5213-
class Evil:
5214-
def __eq__(evil, other):
5215-
k.obj = None
5216-
self.assertIsNotNone(wr())
5217-
return True
5218-
K = functools.cmp_to_key(list.__eq__)
5219-
k = K(L([Evil()]))
5220-
wr = weakref.ref(k.obj)
5221-
k < K([1])
5222-
52235206
def test_mixing_slot_wrappers(self):
52245207
class X(dict):
52255208
__setattr__ = dict.__setitem__

‎Objects/descrobject.c‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -567,10 +567,7 @@ wrapperdescr_impl(PyObject *_descr, PyObject *const *args,
567567
if (argstuple == NULL) {
568568
return NULL;
569569
}
570-
/* Turn vectorcall borrowed reference into a strong reference */
571-
Py_INCREF(self);
572570
result = wrapperdescr_raw_call(descr, self, argstuple, kwds);
573-
Py_DECREF(self);
574571
Py_DECREF(argstuple);
575572
return result;
576573
}

0 commit comments

Comments
 (0)