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 /Python | |
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 'Python')
-rw-r--r-- | Python/_warnings.c | 4 | ||||
-rw-r--r-- | Python/ceval.c | 2 | ||||
-rw-r--r-- | Python/codecs.c | 12 | ||||
-rw-r--r-- | Python/dynload_shlib.c | 4 | ||||
-rw-r--r-- | Python/import.c | 6 | ||||
-rw-r--r-- | Python/pylifecycle.c | 2 | ||||
-rw-r--r-- | Python/pystate.c | 2 | ||||
-rw-r--r-- | Python/pythonrun.c | 2 | ||||
-rw-r--r-- | Python/sysmodule.c | 4 | ||||
-rw-r--r-- | Python/thread.c | 2 | ||||
-rw-r--r-- | Python/thread_nt.h | 4 | ||||
-rw-r--r-- | Python/thread_pthread.h | 4 |
12 files changed, 24 insertions, 24 deletions
diff --git a/Python/_warnings.c b/Python/_warnings.c index d005f12..0236cab 100644 --- a/Python/_warnings.c +++ b/Python/_warnings.c @@ -212,7 +212,7 @@ get_warnings_attr(_Py_Identifier *attr_id, int try_import) gone, then we can't even use PyImport_GetModule without triggering an interpreter abort. */ - if (!_PyInterpreterState_GET_UNSAFE()->modules) { + if (!_PyInterpreterState_GET()->modules) { return NULL; } warnings_module = PyImport_GetModule(warnings_str); @@ -840,7 +840,7 @@ setup_context(Py_ssize_t stack_level, PyObject **filename, int *lineno, } if (f == NULL) { - globals = _PyInterpreterState_GET_UNSAFE()->sysdict; + globals = _PyInterpreterState_GET()->sysdict; *filename = PyUnicode_FromString("sys"); *lineno = 1; } diff --git a/Python/ceval.c b/Python/ceval.c index b712920..fc720b4 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -5562,7 +5562,7 @@ _Py_GetDXProfile(PyObject *self, PyObject *args) Py_ssize_t _PyEval_RequestCodeExtraIndex(freefunc free) { - PyInterpreterState *interp = _PyInterpreterState_GET_UNSAFE(); + PyInterpreterState *interp = _PyInterpreterState_GET(); Py_ssize_t new_index; if (interp->co_extra_user_count == MAX_CO_EXTRA_USERS - 1) { diff --git a/Python/codecs.c b/Python/codecs.c index 6691985..32cc110 100644 --- a/Python/codecs.c +++ b/Python/codecs.c @@ -33,7 +33,7 @@ static int _PyCodecRegistry_Init(void); /* Forward */ int PyCodec_Register(PyObject *search_function) { - PyInterpreterState *interp = _PyInterpreterState_GET_UNSAFE(); + PyInterpreterState *interp = _PyInterpreterState_GET(); if (interp->codec_search_path == NULL && _PyCodecRegistry_Init()) goto onError; if (search_function == NULL) { @@ -105,7 +105,7 @@ PyObject *_PyCodec_Lookup(const char *encoding) return NULL; } - PyInterpreterState *interp = _PyInterpreterState_GET_UNSAFE(); + PyInterpreterState *interp = _PyInterpreterState_GET(); if (interp->codec_search_path == NULL && _PyCodecRegistry_Init()) { return NULL; } @@ -188,7 +188,7 @@ int _PyCodec_Forget(const char *encoding) PyObject *v; int result; - PyInterpreterState *interp = _PyInterpreterState_GET_UNSAFE(); + PyInterpreterState *interp = _PyInterpreterState_GET(); if (interp->codec_search_path == NULL) { return -1; } @@ -621,7 +621,7 @@ PyObject *_PyCodec_DecodeText(PyObject *object, Return 0 on success, -1 on error */ int PyCodec_RegisterError(const char *name, PyObject *error) { - PyInterpreterState *interp = _PyInterpreterState_GET_UNSAFE(); + PyInterpreterState *interp = _PyInterpreterState_GET(); if (interp->codec_search_path == NULL && _PyCodecRegistry_Init()) return -1; if (!PyCallable_Check(error)) { @@ -639,7 +639,7 @@ PyObject *PyCodec_LookupError(const char *name) { PyObject *handler = NULL; - PyInterpreterState *interp = _PyInterpreterState_GET_UNSAFE(); + PyInterpreterState *interp = _PyInterpreterState_GET(); if (interp->codec_search_path == NULL && _PyCodecRegistry_Init()) return NULL; @@ -1491,7 +1491,7 @@ static int _PyCodecRegistry_Init(void) } }; - PyInterpreterState *interp = _PyInterpreterState_GET_UNSAFE(); + PyInterpreterState *interp = _PyInterpreterState_GET(); PyObject *mod; if (interp->codec_search_path != NULL) diff --git a/Python/dynload_shlib.c b/Python/dynload_shlib.c index 223e0d0..082154d 100644 --- a/Python/dynload_shlib.c +++ b/Python/dynload_shlib.c @@ -3,7 +3,7 @@ #include "Python.h" #include "pycore_interp.h" // _PyInterpreterState.dlopenflags -#include "pycore_pystate.h" // _PyInterpreterState_GET_UNSAFE() +#include "pycore_pystate.h" // _PyInterpreterState_GET() #include "importdl.h" #include <sys/types.h> @@ -95,7 +95,7 @@ _PyImport_FindSharedFuncptr(const char *prefix, } } - dlopenflags = _PyInterpreterState_GET_UNSAFE()->dlopenflags; + dlopenflags = _PyInterpreterState_GET()->dlopenflags; handle = dlopen(pathname, dlopenflags); diff --git a/Python/import.c b/Python/import.c index 3bf8fe0..042691d 100644 --- a/Python/import.c +++ b/Python/import.c @@ -310,7 +310,7 @@ _PyImport_Fini2(void) PyObject * PyImport_GetModuleDict(void) { - PyInterpreterState *interp = _PyInterpreterState_GET_UNSAFE(); + PyInterpreterState *interp = _PyInterpreterState_GET(); if (interp->modules == NULL) { Py_FatalError("interpreter has no modules dictionary"); } @@ -644,7 +644,7 @@ long PyImport_GetMagicNumber(void) { long res; - PyInterpreterState *interp = _PyInterpreterState_GET_UNSAFE(); + PyInterpreterState *interp = _PyInterpreterState_GET(); PyObject *external, *pyc_magic; external = PyObject_GetAttrString(interp->importlib, "_bootstrap_external"); @@ -980,7 +980,7 @@ PyImport_ExecCodeModuleWithPathnames(const char *name, PyObject *co, goto error; } else if (cpathobj != NULL) { - PyInterpreterState *interp = _PyInterpreterState_GET_UNSAFE(); + PyInterpreterState *interp = _PyInterpreterState_GET(); _Py_IDENTIFIER(_get_sourcefile); if (interp == NULL) { diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index c2a0781..ac0ea10 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -2355,7 +2355,7 @@ Py_ExitStatusException(PyStatus status) /* For the atexit module. */ void _Py_PyAtExit(void (*func)(PyObject *), PyObject *module) { - PyInterpreterState *is = _PyInterpreterState_GET_UNSAFE(); + PyInterpreterState *is = _PyInterpreterState_GET(); /* Guard against API misuse (see bpo-17852) */ assert(is->pyexitfunc == NULL || is->pyexitfunc == func); diff --git a/Python/pystate.c b/Python/pystate.c index 3636dc9..65d46a2 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -661,7 +661,7 @@ PyObject* PyState_FindModule(struct PyModuleDef* module) { Py_ssize_t index = module->m_base.m_index; - PyInterpreterState *state = _PyInterpreterState_GET_UNSAFE(); + PyInterpreterState *state = _PyInterpreterState_GET(); PyObject *res; if (module->m_slots) { return NULL; diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 522d152..d1165e2 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -347,7 +347,7 @@ set_main_loader(PyObject *d, const char *filename, const char *loader_name) filename_obj = PyUnicode_DecodeFSDefault(filename); if (filename_obj == NULL) return -1; - PyInterpreterState *interp = _PyInterpreterState_GET_UNSAFE(); + PyInterpreterState *interp = _PyInterpreterState_GET(); bootstrap = PyObject_GetAttrString(interp->importlib, "_bootstrap_external"); if (bootstrap != NULL) { diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 814e4ab..6b3a1c3 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -847,7 +847,7 @@ static PyObject * sys_getfilesystemencoding_impl(PyObject *module) /*[clinic end generated code: output=1dc4bdbe9be44aa7 input=8475f8649b8c7d8c]*/ { - PyInterpreterState *interp = _PyInterpreterState_GET_UNSAFE(); + PyInterpreterState *interp = _PyInterpreterState_GET(); const PyConfig *config = _PyInterpreterState_GetConfig(interp); return PyUnicode_FromWideChar(config->filesystem_encoding, -1); } @@ -862,7 +862,7 @@ static PyObject * sys_getfilesystemencodeerrors_impl(PyObject *module) /*[clinic end generated code: output=ba77b36bbf7c96f5 input=22a1e8365566f1e5]*/ { - PyInterpreterState *interp = _PyInterpreterState_GET_UNSAFE(); + PyInterpreterState *interp = _PyInterpreterState_GET(); const PyConfig *config = _PyInterpreterState_GetConfig(interp); return PyUnicode_FromWideChar(config->filesystem_errors, -1); } diff --git a/Python/thread.c b/Python/thread.c index ec6909c..bac0e69 100644 --- a/Python/thread.c +++ b/Python/thread.c @@ -92,7 +92,7 @@ PyThread_init_thread(void) size_t PyThread_get_stacksize(void) { - return _PyInterpreterState_GET_UNSAFE()->pythread_stacksize; + return _PyInterpreterState_GET()->pythread_stacksize; } /* Only platforms defining a THREAD_SET_STACKSIZE() macro diff --git a/Python/thread_nt.h b/Python/thread_nt.h index e4bd0f7..05b982d 100644 --- a/Python/thread_nt.h +++ b/Python/thread_nt.h @@ -359,13 +359,13 @@ _pythread_nt_set_stacksize(size_t size) { /* set to default */ if (size == 0) { - _PyInterpreterState_GET_UNSAFE()->pythread_stacksize = 0; + _PyInterpreterState_GET()->pythread_stacksize = 0; return 0; } /* valid range? */ if (size >= THREAD_MIN_STACKSIZE && size < THREAD_MAX_STACKSIZE) { - _PyInterpreterState_GET_UNSAFE()->pythread_stacksize = size; + _PyInterpreterState_GET()->pythread_stacksize = size; return 0; } diff --git a/Python/thread_pthread.h b/Python/thread_pthread.h index 440d845..cf4e854 100644 --- a/Python/thread_pthread.h +++ b/Python/thread_pthread.h @@ -735,7 +735,7 @@ _pythread_pthread_set_stacksize(size_t size) /* set to default */ if (size == 0) { - _PyInterpreterState_GET_UNSAFE()->pythread_stacksize = 0; + _PyInterpreterState_GET()->pythread_stacksize = 0; return 0; } @@ -752,7 +752,7 @@ _pythread_pthread_set_stacksize(size_t size) rc = pthread_attr_setstacksize(&attrs, size); pthread_attr_destroy(&attrs); if (rc == 0) { - _PyInterpreterState_GET_UNSAFE()->pythread_stacksize = size; + _PyInterpreterState_GET()->pythread_stacksize = size; return 0; } } |