bpo-39947: Use _PyInterpreterState_GET_UNSAFE() (GH-18978) · python/cpython@ff4584c

@@ -451,7 +451,7 @@ run_at_forkers(PyObject *lst, int reverse)

451451

void

452452

PyOS_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)

462462

if (_PyImport_ReleaseLock() <= 0)

463463

Py_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

}

467467468468

void

@@ -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

}

481481482482

static int

@@ -6177,7 +6177,7 @@ os_register_at_fork_impl(PyObject *module, PyObject *before,

61776177

check_null_or_callable(after_in_parent, "after_in_parent")) {

61786178

return NULL;

61796179

}

6180-

interp = _PyInterpreterState_Get();

6180+

interp = _PyInterpreterState_GET_UNSAFE();

6181618161826182

if (register_at_forker(&interp->before_forkers, before)) {

61836183

return NULL;

@@ -6208,7 +6208,7 @@ os_fork1_impl(PyObject *module)

62086208

{

62096209

pid_t pid;

621062106211-

if (_PyInterpreterState_Get() != PyInterpreterState_Main()) {

6211+

if (_PyInterpreterState_GET_UNSAFE() != PyInterpreterState_Main()) {

62126212

PyErr_SetString(PyExc_RuntimeError, "fork not supported for subinterpreters");

62136213

return NULL;

62146214

}

@@ -6243,7 +6243,7 @@ os_fork_impl(PyObject *module)

62436243

{

62446244

pid_t pid;

624562456246-

if (_PyInterpreterState_Get() != PyInterpreterState_Main()) {

6246+

if (_PyInterpreterState_GET_UNSAFE() != PyInterpreterState_Main()) {

62476247

PyErr_SetString(PyExc_RuntimeError, "fork not supported for subinterpreters");

62486248

return NULL;

62496249

}

@@ -6851,7 +6851,7 @@ os_forkpty_impl(PyObject *module)

68516851

int master_fd = -1;

68526852

pid_t pid;

685368536854-

if (_PyInterpreterState_Get() != PyInterpreterState_Main()) {

6854+

if (_PyInterpreterState_GET_UNSAFE() != PyInterpreterState_Main()) {

68556855

PyErr_SetString(PyExc_RuntimeError, "fork not supported for subinterpreters");

68566856

return NULL;

68576857

}