Skip to content

Commit eeb0936

Browse files
In setup_context, replace _PyDict_GetItemWithError with PyDict_GetItemRef
1 parent d05c678 commit eeb0936

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Python/_warnings.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -932,18 +932,18 @@ setup_context(Py_ssize_t stack_level,
932932
}
933933

934934
/* Setup module. */
935-
*module = _PyDict_GetItemWithError(globals, &_Py_ID(__name__));
936-
if (*module == Py_None || (*module != NULL && PyUnicode_Check(*module))) {
937-
Py_INCREF(*module);
938-
}
939-
else if (_PyErr_Occurred(tstate)) {
935+
rc = PyDict_GetItemRef(globals, &_Py_ID(__name__), module);
936+
if (rc < 0) {
940937
goto handle_error;
941938
}
942-
else {
939+
if (rc == 0) {
943940
*module = PyUnicode_FromString("<string>");
944941
if (*module == NULL)
945942
goto handle_error;
946943
}
944+
else {
945+
assert(Py_IsNone(*module) || PyUnicode_Check(*module));
946+
}
947947

948948
return 1;
949949

0 commit comments

Comments
 (0)