mirror of
https://github.com/python/cpython.git
synced 2025-09-19 15:10:58 +00:00
bpo-34301: Add _PyInterpreterState_Get() helper function (GH-8592)
sys_setcheckinterval() now uses a local variable to parse arguments, before writing into interp->check_interval.
This commit is contained in:
parent
2ebd3813af
commit
caba55b3b7
22 changed files with 107 additions and 93 deletions
|
@ -32,7 +32,7 @@ static int _PyCodecRegistry_Init(void); /* Forward */
|
|||
|
||||
int PyCodec_Register(PyObject *search_function)
|
||||
{
|
||||
PyInterpreterState *interp = PyThreadState_GET()->interp;
|
||||
PyInterpreterState *interp = _PyInterpreterState_Get();
|
||||
if (interp->codec_search_path == NULL && _PyCodecRegistry_Init())
|
||||
goto onError;
|
||||
if (search_function == NULL) {
|
||||
|
@ -99,7 +99,6 @@ PyObject *normalizestring(const char *string)
|
|||
|
||||
PyObject *_PyCodec_Lookup(const char *encoding)
|
||||
{
|
||||
PyInterpreterState *interp;
|
||||
PyObject *result, *args = NULL, *v;
|
||||
Py_ssize_t i, len;
|
||||
|
||||
|
@ -108,7 +107,7 @@ PyObject *_PyCodec_Lookup(const char *encoding)
|
|||
goto onError;
|
||||
}
|
||||
|
||||
interp = PyThreadState_GET()->interp;
|
||||
PyInterpreterState *interp = _PyInterpreterState_GET_UNSAFE();
|
||||
if (interp->codec_search_path == NULL && _PyCodecRegistry_Init())
|
||||
goto onError;
|
||||
|
||||
|
@ -187,11 +186,10 @@ PyObject *_PyCodec_Lookup(const char *encoding)
|
|||
|
||||
int _PyCodec_Forget(const char *encoding)
|
||||
{
|
||||
PyInterpreterState *interp;
|
||||
PyObject *v;
|
||||
int result;
|
||||
|
||||
interp = PyThreadState_GET()->interp;
|
||||
PyInterpreterState *interp = _PyInterpreterState_Get();
|
||||
if (interp->codec_search_path == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -624,7 +622,7 @@ PyObject *_PyCodec_DecodeText(PyObject *object,
|
|||
Return 0 on success, -1 on error */
|
||||
int PyCodec_RegisterError(const char *name, PyObject *error)
|
||||
{
|
||||
PyInterpreterState *interp = PyThreadState_GET()->interp;
|
||||
PyInterpreterState *interp = _PyInterpreterState_Get();
|
||||
if (interp->codec_search_path == NULL && _PyCodecRegistry_Init())
|
||||
return -1;
|
||||
if (!PyCallable_Check(error)) {
|
||||
|
@ -642,7 +640,7 @@ PyObject *PyCodec_LookupError(const char *name)
|
|||
{
|
||||
PyObject *handler = NULL;
|
||||
|
||||
PyInterpreterState *interp = PyThreadState_GET()->interp;
|
||||
PyInterpreterState *interp = _PyInterpreterState_GET_UNSAFE();
|
||||
if (interp->codec_search_path == NULL && _PyCodecRegistry_Init())
|
||||
return NULL;
|
||||
|
||||
|
@ -1494,7 +1492,7 @@ static int _PyCodecRegistry_Init(void)
|
|||
}
|
||||
};
|
||||
|
||||
PyInterpreterState *interp = PyThreadState_GET()->interp;
|
||||
PyInterpreterState *interp = _PyInterpreterState_Get();
|
||||
PyObject *mod;
|
||||
unsigned i;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue