Skip to content

Commit 62b3d5e

Browse files
Fix clear_current_module().
1 parent 3de1cd3 commit 62b3d5e

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

Modules/_datetimemodule.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,15 @@ clear_current_module(PyInterpreterState *interp, PyObject *expected)
166166
if (PyDict_GetItemStringRef(dict, INTERP_KEY, &ref) < 0) {
167167
goto error;
168168
}
169-
int rc = PyWeakref_GetRef(ref, &current);
170-
Py_DECREF(ref);
171-
if (rc < 0) {
172-
goto error;
173-
}
174-
if (current != expected) {
175-
goto finally;
169+
if (ref != NULL) {
170+
int rc = PyWeakref_GetRef(ref, &current);
171+
Py_DECREF(ref);
172+
if (rc < 0) {
173+
goto error;
174+
}
175+
if (current != expected) {
176+
goto finally;
177+
}
176178
}
177179
}
178180

0 commit comments

Comments
 (0)