8000 gh-81057: Move OS-Related Globals to _PyRuntimeState by ericsnowcurrently · Pull Request #100082 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-81057: Move OS-Related Globals to _PyRuntimeState #100082

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
Store the original tp_new in module state.
  • Loading branch information
ericsnowcurrently committed Dec 8, 2022
commit b8befdc09473a49bc8048b72e28e6fa778b7a0ad
8 changes: 6 additions & 2 deletions Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -976,6 +976,7 @@ typedef struct {
#if defined(HAVE_SCHED_SETPARAM) || defined(HAVE_SCHED_SETSCHEDULER) || defined(POSIX_SPAWN_SETSCHEDULER) || defined(POSIX_SPAWN_SETSCHEDPARAM)
PyObject *SchedParamType;
#endif
newfunc statresult_new_orig;
PyObject *StatResultType;
PyObject *StatVFSResultType;
PyObject *TerminalSizeType;
Expand Down Expand Up @@ -2234,15 +2235,17 @@ statresult_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyStructSequence *result;
int i;

PyObject *mod = PyType_GetModule(type);
// ht_module doesn't get set in PyStructSequence_NewType(),
// so we can't use PyType_GetModule().
PyObject *mod = PyImport_GetModule(MODNAME_OBJ);
if (mod == NULL) {
return NULL;
}
_posixstate *state = get_posix_state(mod);
if (state == NULL) {
return NULL;
}
#define structseq_new ((PyTypeObject *)state->StatResultType)->tp_new
#define structseq_new state->statresult_new_orig

result = (PyStructSequence*)structseq_new(type, args, kwds);
if (!result)
Expand Down Expand Up @@ -15936,6 +15939,7 @@ posixmodule_exec(PyObject *m)
}
PyModule_AddObject(m, "stat_result", Py_NewRef(StatResultType));
state->StatResultType = StatResultType;
state->statresult_new_orig = ((PyTypeObject *)StatResultType)->tp_new;
((PyTypeObject *)StatResultType)->tp_new = statresult_new;

statvfs_result_desc.name = "os.statvfs_result"; /* see issue #19209 */
Expand Down
0