Skip to content
Merged
Prev Previous commit
Next Next commit
Address PR comments
  • Loading branch information
benjaminJohnson2204 committed Jul 18, 2024
commit 90568246691435ac49cab85ecd0e153a7d53a19b
8 changes: 6 additions & 2 deletions Lib/test/_test_atexit.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,17 @@ def __call__(self):
return

def __eq__(self, o):
nonlocal cnt
cnt += 1
if cnt == 1:
self.action(o)
return self.eq_ret_val(o)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.eq_ret_val is not callable.


for action in lambda o: atexit.unregister(self), \
lambda o: atexit.unregister(o), lambda o: atexit._clear():
for action in (
lambda o: atexit.unregister(self),
lambda o: atexit.unregister(o),
lambda o: atexit._clear()
):
for eq_ret_val in NotImplemented, True:
with self.subTest(action=action, eq_ret_val=eq_ret_val):
cnt = 0
Expand Down
2 changes: 0 additions & 2 deletions Modules/atexitmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,8 @@ atexit_unregister(PyObject *module, PyObject *func)
* unregister one or both
*/
PyObject *cb_func = Py_NewRef(cb->func);
PyObject *cur_func = Py_NewRef(func);
int eq = PyObject_RichCompareBool(cb->func, func, Py_EQ);
Py_DECREF(cb_func);
Py_DECREF(cur_func);
if (eq < 0) {
return NULL;
}
Expand Down