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

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 98e3e4e

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

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

Python/_warnings.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -917,13 +917,12 @@ setup_context(Py_ssize_t stack_level,
917917
/* Setup registry. */
918918
assert(globals != NULL);
919919
assert(PyDict_Check(globals));
920-
*registry = _PyDict_GetItemWithError(globals, &_Py_ID(__warningregistry__));
920+
int rc = PyDict_GetItemRef(globals, &_Py_ID(__warningregistry__),
921+
registry);
922+
if (rc < 0) {
923+
goto handle_error;
924+
}
921925
if (*registry == NULL) {
922-
int rc;
923-
924-
if (_PyErr_Occurred(tstate)) {
925-
goto handle_error;
926-
}
927926
*registry = PyDict_New();
928927
if (*registry == NULL)
929928
goto handle_error;
@@ -932,8 +931,6 @@ setup_context(Py_ssize_t stack_level,
932931
if (rc < 0)
933932
goto handle_error;
934933
}
935-
else
936-
Py_INCREF(*registry);
937934

938935
/* Setup module. */
939936
*module = _PyDict_GetItemWithError(globals, &_Py_ID(__name__));

0 commit comments

Comments
 (0)
0