Skip to content

Commit 9056824

Browse files
Address PR comments
1 parent 1148d80 commit 9056824

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

Lib/test/_test_atexit.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,17 @@ def __call__(self):
147147
return
148148

149149
def __eq__(self, o):
150+
nonlocal cnt
150151
cnt += 1
151152
if cnt == 1:
152153
self.action(o)
153154
return self.eq_ret_val(o)
154155

155-
for action in lambda o: atexit.unregister(self), \
156-
lambda o: atexit.unregister(o), lambda o: atexit._clear():
156+
for action in (
157+
lambda o: atexit.unregister(self),
158+
lambda o: atexit.unregister(o),
159+
lambda o: atexit._clear()
160+
):
157161
for eq_ret_val in NotImplemented, True:
158162
with self.subTest(action=action, eq_ret_val=eq_ret_val):
159163
cnt = 0

Modules/atexitmodule.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,10 +288,8 @@ atexit_unregister(PyObject *module, PyObject *func)
288288
* unregister one or both
289289
*/
290290
PyObject *cb_func = Py_NewRef(cb->func);
291-
PyObject *cur_func = Py_NewRef(func);
292291
int eq = PyObject_RichCompareBool(cb->func, func, Py_EQ);
293292
Py_DECREF(cb_func);
294-
Py_DECREF(cur_func);
295293
if (eq < 0) {
296294
return NULL;
297295
}

0 commit comments

Comments
 (0)