summaryrefslogtreecommitdiff
path: root/Python/codecs.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2018-08-03 15:33:52 +0200
committerGitHub <noreply@github.com>2018-08-03 15:33:52 +0200
commitcaba55b3b735405b280273f7d99866a046c18281 (patch)
tree3a98ac383b1fbab272158933255fb1a14107ebf6 /Python/codecs.c
parent2ebd3813af9172fe1f9b2f6004edf6f1e1e5d9f1 (diff)
downloadcpython-git-caba55b3b735405b280273f7d99866a046c18281.tar.gz
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.
Diffstat (limited to 'Python/codecs.c')
-rw-r--r--Python/codecs.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/Python/codecs.c b/Python/codecs.c
index eb3cd35fb8..4062429fe3 100644
--- a/Python/codecs.c
+++ b/Python/codecs.c
@@ -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;