diff options
author | Victor Stinner <vstinner@python.org> | 2020-04-14 13:14:01 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-14 13:14:01 (GMT) |
commit | 81a7be3fa22c983209cc0ffb3537b92b0370f83c (patch) | |
tree | c257d7143ecc60574353caa76fa2992a455ebb54 /Modules | |
parent | 4a3fe0835310643193ea45529ab0fb45c5f8f2fd (diff) | |
download | cpython-81a7be3fa22c983209cc0ffb3537b92b0370f83c.zip cpython-81a7be3fa22c983209cc0ffb3537b92b0370f83c.tar.gz cpython-81a7be3fa22c983209cc0ffb3537b92b0370f83c.tar.bz2 |
bpo-40268: Rename _PyInterpreterState_GET_UNSAFE() (GH-19509)
Rename _PyInterpreterState_GET_UNSAFE() to _PyInterpreterState_GET()
for consistency with _PyThreadState_GET() and to have a shorter name
(help to fit into 80 columns).
Add also "assert(tstate != NULL);" to the function.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_io/textio.c | 2 | ||||
-rw-r--r-- | Modules/_threadmodule.c | 6 | ||||
-rw-r--r-- | Modules/main.c | 2 | ||||
-rw-r--r-- | Modules/posixmodule.c | 14 | ||||
-rw-r--r-- | Modules/signalmodule.c | 4 |
5 files changed, 14 insertions, 14 deletions
diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c index 492988e..95b023d 100644 --- a/Modules/_io/textio.c +++ b/Modules/_io/textio.c @@ -994,7 +994,7 @@ io_check_errors(PyObject *errors) { assert(errors != NULL && errors != Py_None); - PyInterpreterState *interp = _PyInterpreterState_GET_UNSAFE(); + PyInterpreterState *interp = _PyInterpreterState_GET(); #ifndef Py_DEBUG /* In release mode, only check in development mode (-X dev) */ if (!_PyInterpreterState_GetConfig(interp)->dev_mode) { diff --git a/Modules/_threadmodule.c b/Modules/_threadmodule.c index 9853699..5636140 100644 --- a/Modules/_threadmodule.c +++ b/Modules/_threadmodule.c @@ -1091,7 +1091,7 @@ thread_PyThread_start_new_thread(PyObject *self, PyObject *fargs) boot = PyMem_NEW(struct bootstate, 1); if (boot == NULL) return PyErr_NoMemory(); - boot->interp = _PyInterpreterState_GET_UNSAFE(); + boot->interp = _PyInterpreterState_GET(); boot->func = func; boot->args = args; boot->keyw = keyw; @@ -1213,7 +1213,7 @@ particular thread within a system."); static PyObject * thread__count(PyObject *self, PyObject *Py_UNUSED(ignored)) { - PyInterpreterState *interp = _PyInterpreterState_GET_UNSAFE(); + PyInterpreterState *interp = _PyInterpreterState_GET(); return PyLong_FromLong(interp->num_threads); } @@ -1556,7 +1556,7 @@ PyInit__thread(void) PyObject *m, *d, *v; double time_max; double timeout_max; - PyInterpreterState *interp = _PyInterpreterState_GET_UNSAFE(); + PyInterpreterState *interp = _PyInterpreterState_GET(); /* Initialize types: */ if (PyType_Ready(&localdummytype) < 0) diff --git a/Modules/main.c b/Modules/main.c index a9de70b..fb24c6c 100644 --- a/Modules/main.c +++ b/Modules/main.c @@ -498,7 +498,7 @@ pymain_repl(PyConfig *config, PyCompilerFlags *cf, int *exitcode) static void pymain_run_python(int *exitcode) { - PyInterpreterState *interp = _PyInterpreterState_GET_UNSAFE(); + PyInterpreterState *interp = _PyInterpreterState_GET(); /* pymain_run_stdin() modify the config */ PyConfig *config = (PyConfig*)_PyInterpreterState_GetConfig(interp); diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 57f1487..2d603d1 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -451,7 +451,7 @@ run_at_forkers(PyObject *lst, int reverse) void PyOS_BeforeFork(void) { - run_at_forkers(_PyInterpreterState_GET_UNSAFE()->before_forkers, 1); + run_at_forkers(_PyInterpreterState_GET()->before_forkers, 1); _PyImport_AcquireLock(); } @@ -462,7 +462,7 @@ PyOS_AfterFork_Parent(void) if (_PyImport_ReleaseLock() <= 0) Py_FatalError("failed releasing import lock after fork"); - run_at_forkers(_PyInterpreterState_GET_UNSAFE()->after_forkers_parent, 0); + run_at_forkers(_PyInterpreterState_GET()->after_forkers_parent, 0); } void @@ -476,7 +476,7 @@ PyOS_AfterFork_Child(void) _PyRuntimeState_ReInitThreads(runtime); _PyInterpreterState_DeleteExceptMain(runtime); - run_at_forkers(_PyInterpreterState_GET_UNSAFE()->after_forkers_child, 0); + run_at_forkers(_PyInterpreterState_GET()->after_forkers_child, 0); } static int @@ -6185,7 +6185,7 @@ os_register_at_fork_impl(PyObject *module, PyObject *before, check_null_or_callable(after_in_parent, "after_in_parent")) { return NULL; } - interp = _PyInterpreterState_GET_UNSAFE(); + interp = _PyInterpreterState_GET(); if (register_at_forker(&interp->before_forkers, before)) { return NULL; @@ -6216,7 +6216,7 @@ os_fork1_impl(PyObject *module) { pid_t pid; - if (_PyInterpreterState_GET_UNSAFE() != PyInterpreterState_Main()) { + if (_PyInterpreterState_GET() != PyInterpreterState_Main()) { PyErr_SetString(PyExc_RuntimeError, "fork not supported for subinterpreters"); return NULL; } @@ -6251,7 +6251,7 @@ os_fork_impl(PyObject *module) { pid_t pid; - if (_PyInterpreterState_GET_UNSAFE() != PyInterpreterState_Main()) { + if (_PyInterpreterState_GET() != PyInterpreterState_Main()) { PyErr_SetString(PyExc_RuntimeError, "fork not supported for subinterpreters"); return NULL; } @@ -6859,7 +6859,7 @@ os_forkpty_impl(PyObject *module) int master_fd = -1; pid_t pid; - if (_PyInterpreterState_GET_UNSAFE() != PyInterpreterState_Main()) { + if (_PyInterpreterState_GET() != PyInterpreterState_Main()) { PyErr_SetString(PyExc_RuntimeError, "fork not supported for subinterpreters"); return NULL; } diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c index b089a80..ceb986b 100644 --- a/Modules/signalmodule.c +++ b/Modules/signalmodule.c @@ -1784,7 +1784,7 @@ PyOS_FiniInterrupts(void) int PyOS_InterruptOccurred(void) { - PyInterpreterState *interp = _PyInterpreterState_GET_UNSAFE(); + PyInterpreterState *interp = _PyInterpreterState_GET(); if (!_Py_ThreadCanHandleSignals(interp)) { return 0; } @@ -1821,7 +1821,7 @@ _PySignal_AfterFork(void) int _PyOS_IsMainThread(void) { - PyInterpreterState *interp = _PyInterpreterState_GET_UNSAFE(); + PyInterpreterState *interp = _PyInterpreterState_GET(); return _Py_ThreadCanHandleSignals(interp); } |