10000 gh-117953: Cleanups For fix_up_extension() in import.c by ericsnowcurrently · Pull Request #118192 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-117953: Cleanups For fix_up_extension() in import.c #118192

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

Merged
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
We already know the def is okay.
  • Loading branch information
ericsnowcurrently committed Apr 23, 2024
commit 319c4613182d9b42c447b2255dd699a63900dd0c
18 changes: 9 additions & 9 deletions Python/import.c
Original file line number Diff line number Diff line change
Expand Up @@ -1197,13 +1197,8 @@ fix_up_extension(PyThreadState *tstate, PyObject *mod, PyModuleDef *def,
PyObject *name, PyObject *path,
PyObject *modules)
{
if (def == NULL) {
def = PyModule_GetDef(mod);
if (def == NULL) {
PyErr_BadInternalCall();
return -1;
}
}
assert(mod != NULL && PyModule_Check(mod));
assert(def == _PyModule_GetDef(mod));

if (fix_up_extension_for_interpreter(
tstate, mod, def, name, path, modules) < 0)
Expand Down Expand Up @@ -1247,7 +1242,6 @@ fix_up_extension(PyThreadState *tstate, PyObject *mod, PyModuleDef *def,

return 0;


error:
PyMapping_DelItem(modules, name);
return -1;
Expand All @@ -1261,8 +1255,14 @@ _PyImport_FixupExtensionObject(PyObject *mod, PyObject *name,
PyErr_BadInternalCall();
return -1;
}
PyModuleDef *def = PyModule_GetDef(mod);
if (def == NULL) {
PyErr_BadInternalCall();
return -1;
}

PyThreadState *tstate = _PyThreadState_GET();
if (fix_up_extension(tstate, mod, NULL, name, filename, modules) < 0) {
if (fix_up_extension(tstate, mod, def, name, filename, modules) < 0) {
return -1;
}
return 0;
Expand Down
0