bpo-39947: Use _PyInterpreterState_GET_UNSAFE() (GH-18978) · python/cpython@ff4584c
@@ -451,7 +451,7 @@ run_at_forkers(PyObject *lst, int reverse)
451451void
452452PyOS_BeforeFork(void)
453453{
454-run_at_forkers(_PyInterpreterState_Get()->before_forkers, 1);
454+run_at_forkers(_PyInterpreterState_GET_UNSAFE()->before_forkers, 1);
455455456456_PyImport_AcquireLock();
457457}
@@ -462,7 +462,7 @@ PyOS_AfterFork_Parent(void)
462462if (_PyImport_ReleaseLock() <= 0)
463463Py_FatalError("failed releasing import lock after fork");
464464465-run_at_forkers(_PyInterpreterState_Get()->after_forkers_parent, 0);
465+run_at_forkers(_PyInterpreterState_GET_UNSAFE()->after_forkers_parent, 0);
466466}
467467468468void
@@ -476,7 +476,7 @@ PyOS_AfterFork_Child(void)
476476_PyRuntimeState_ReInitThreads(runtime);
477477_PyInterpreterState_DeleteExceptMain(runtime);
478478479-run_at_forkers(_PyInterpreterState_Get()->after_forkers_child, 0);
479+run_at_forkers(_PyInterpreterState_GET_UNSAFE()->after_forkers_child, 0);
480480}
481481482482static int
@@ -6177,7 +6177,7 @@ os_register_at_fork_impl(PyObject *module, PyObject *before,
61776177check_null_or_callable(after_in_parent, "after_in_parent")) {
61786178return NULL;
61796179 }
6180-interp = _PyInterpreterState_Get();
6180+interp = _PyInterpreterState_GET_UNSAFE();
6181618161826182if (register_at_forker(&interp->before_forkers, before)) {
61836183return NULL;
@@ -6208,7 +6208,7 @@ os_fork1_impl(PyObject *module)
62086208{
62096209pid_t pid;
621062106211-if (_PyInterpreterState_Get() != PyInterpreterState_Main()) {
6211+if (_PyInterpreterState_GET_UNSAFE() != PyInterpreterState_Main()) {
62126212PyErr_SetString(PyExc_RuntimeError, "fork not supported for subinterpreters");
62136213return NULL;
62146214 }
@@ -6243,7 +6243,7 @@ os_fork_impl(PyObject *module)
62436243{
62446244pid_t pid;
624562456246-if (_PyInterpreterState_Get() != PyInterpreterState_Main()) {
6246+if (_PyInterpreterState_GET_UNSAFE() != PyInterpreterState_Main()) {
62476247PyErr_SetString(PyExc_RuntimeError, "fork not supported for subinterpreters");
62486248return NULL;
62496249 }
@@ -6851,7 +6851,7 @@ os_forkpty_impl(PyObject *module)
68516851int master_fd = -1;
68526852pid_t pid;
685368536854-if (_PyInterpreterState_Get() != PyInterpreterState_Main()) {
6854+if (_PyInterpreterState_GET_UNSAFE() != PyInterpreterState_Main()) {
68556855PyErr_SetString(PyExc_RuntimeError, "fork not supported for subinterpreters");
68566856return NULL;
68576857 }