Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-1635741: _warnings uses PyModule_AddObjectRef() #23151

Merged
merged 1 commit into from
Nov 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions Python/_warnings.c
Original file line number Diff line number Diff line change
Expand Up @@ -1395,18 +1395,13 @@ _PyWarnings_Init(void)
goto error;
}

Py_INCREF(st->filters);
if (PyModule_AddObject(m, "filters", st->filters) < 0) {
if (PyModule_AddObjectRef(m, "filters", st->filters) < 0) {
goto error;
}

Py_INCREF(st->once_registry);
if (PyModule_AddObject(m, "_onceregistry", st->once_registry) < 0) {
if (PyModule_AddObjectRef(m, "_onceregistry", st->once_registry) < 0) {
goto error;
}

Py_INCREF(st->default_action);
if (PyModule_AddObject(m, "_defaultaction", st->default_action) < 0) {
if (PyModule_AddObjectRef(m, "_defaultaction", st->default_action) < 0) {
goto error;
}

Expand Down
5 changes: 2 additions & 3 deletions Python/importdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,9 @@ _PyImport_LoadDynamicModuleWithSpec(PyObject *spec, FILE *fp)
def->m_base.m_init = p0;

/* Remember the filename as the __file__ attribute */
if (PyModule_AddObject(m, "__file__", path) < 0)
if (PyModule_AddObjectRef(m, "__file__", path) < 0) {
PyErr_Clear(); /* Not important enough to report */
else
Py_INCREF(path);
}

PyObject *modules = PyImport_GetModuleDict();
if (_PyImport_FixupExtensionObject(m, name_unicode, path, modules) < 0)
Expand Down