8000 In setup_context, replace _PyDict_GetItemWithError with PyDict_GetIte… · python/cpython@89e6f14 · GitHub
[go: up one dir, main page]

Skip to content

Commit 89e6f14

Browse files
In setup_context, replace _PyDict_GetItemWithError with PyDict_GetItemRef
1 parent 98e3e4e commit 89e6f14

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
@@ -933,18 +933,18 @@ setup_context(Py_ssize_t stack_level,
933933
}
934934

935935
/* Setup module. */
936-
*module = < 8000 span class=pl-en>_PyDict_GetItemWithError(globals, &_Py_ID(__name__));
937-
if (*module == Py_None || (*module != NULL && PyUnicode_Check(*module))) {
938-
Py_INCREF(*module);
939-
}
940-
else if (_PyErr_Occurred(tstate)) {
936+
rc = PyDict_GetItemRef(globals, &_Py_ID(__name__), module);
937+
if (rc < 0) {
941938
goto handle_error;
942939
}
943-
else {
940+
if (rc == 0) {
944941
*module = PyUnicode_FromString("<string>");
945942
if (*module == NULL)
946943
goto handle_error;
947944
}
945+
else {
946+
assert(Py_IsNone(*module) || PyUnicode_Check(*module));
947+
}
948948

949949
return 1;
950950

0 commit comments

Comments
 (0)
0