summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
Diffstat (limited to 'Objects')
-rw-r--r--Objects/bytearrayobject.c7
-rw-r--r--Objects/bytesobject.c7
-rw-r--r--Objects/moduleobject.c4
-rw-r--r--Objects/unicodeobject.c16
4 files changed, 15 insertions, 19 deletions
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c
index 7ebfa1f..4d1ddec 100644
--- a/Objects/bytearrayobject.c
+++ b/Objects/bytearrayobject.c
@@ -6,7 +6,6 @@
#include "pycore_bytes_methods.h"
#include "pycore_object.h"
#include "pycore_pymem.h"
-#include "pycore_pystate.h"
#include "structmember.h"
#include "bytesobject.h"
#include "pystrhex.h"
@@ -997,8 +996,7 @@ bytearray_repr(PyByteArrayObject *self)
static PyObject *
bytearray_str(PyObject *op)
{
- PyConfig *config = &_PyInterpreterState_GET_UNSAFE()->config;
- if (config->bytes_warning) {
+ if (_Py_GetConfig()->bytes_warning) {
if (PyErr_WarnEx(PyExc_BytesWarning,
"str() on a bytearray instance", 1)) {
return NULL;
@@ -1023,8 +1021,7 @@ bytearray_richcompare(PyObject *self, PyObject *other, int op)
if (rc < 0)
return NULL;
if (rc) {
- PyConfig *config = &_PyInterpreterState_GET_UNSAFE()->config;
- if (config->bytes_warning && (op == Py_EQ || op == Py_NE)) {
+ if (_Py_GetConfig()->bytes_warning && (op == Py_EQ || op == Py_NE)) {
if (PyErr_WarnEx(PyExc_BytesWarning,
"Comparison between bytearray and string", 1))
return NULL;
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index 7be075b..30bc739 100644
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -7,7 +7,6 @@
#include "pycore_bytes_methods.h"
#include "pycore_object.h"
#include "pycore_pymem.h"
-#include "pycore_pystate.h"
#include "pystrhex.h"
#include <stddef.h>
@@ -1342,8 +1341,7 @@ bytes_repr(PyObject *op)
static PyObject *
bytes_str(PyObject *op)
{
- PyConfig *config = &_PyInterpreterState_GET_UNSAFE()->config;
- if (config->bytes_warning) {
+ if (_Py_GetConfig()->bytes_warning) {
if (PyErr_WarnEx(PyExc_BytesWarning,
"str() on a bytes instance", 1)) {
return NULL;
@@ -1500,8 +1498,7 @@ bytes_richcompare(PyBytesObject *a, PyBytesObject *b, int op)
/* Make sure both arguments are strings. */
if (!(PyBytes_Check(a) && PyBytes_Check(b))) {
- PyConfig *config = &_PyInterpreterState_GET_UNSAFE()->config;
- if (config->bytes_warning && (op == Py_EQ || op == Py_NE)) {
+ if (_Py_GetConfig()->bytes_warning && (op == Py_EQ || op == Py_NE)) {
rc = PyObject_IsInstance((PyObject*)a,
(PyObject*)&PyUnicode_Type);
if (!rc)
diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c
index f02ca75..30adc92 100644
--- a/Objects/moduleobject.c
+++ b/Objects/moduleobject.c
@@ -572,7 +572,7 @@ _PyModule_ClearDict(PyObject *d)
Py_ssize_t pos;
PyObject *key, *value;
- int verbose = _PyInterpreterState_GET_UNSAFE()->config.verbose;
+ int verbose = _Py_GetConfig()->verbose;
/* First, clear only names starting with a single underscore */
pos = 0;
@@ -659,7 +659,7 @@ module___init___impl(PyModuleObject *self, PyObject *name, PyObject *doc)
static void
module_dealloc(PyModuleObject *m)
{
- int verbose = _PyInterpreterState_GET_UNSAFE()->config.verbose;
+ int verbose = _Py_GetConfig()->verbose;
PyObject_GC_UnTrack(m);
if (verbose && m->md_name) {
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 7f39022..938df24 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -439,7 +439,7 @@ unicode_check_encoding_errors(const char *encoding, const char *errors)
PyInterpreterState *interp = _PyInterpreterState_GET_UNSAFE();
#ifndef Py_DEBUG
/* In release mode, only check in development mode (-X dev) */
- if (!interp->config.dev_mode) {
+ if (!_PyInterpreterState_GetConfig(interp)->dev_mode) {
return 0;
}
#else
@@ -3632,7 +3632,8 @@ PyUnicode_EncodeFSDefault(PyObject *unicode)
/* Before _PyUnicode_InitEncodings() is called, the Python codec
machinery is not ready and so cannot be used:
use wcstombs() in this case. */
- const wchar_t *filesystem_errors = interp->config.filesystem_errors;
+ const PyConfig *config = _PyInterpreterState_GetConfig(interp);
+ const wchar_t *filesystem_errors = config->filesystem_errors;
assert(filesystem_errors != NULL);
_Py_error_handler errors = get_error_handler_wide(filesystem_errors);
assert(errors != _Py_ERROR_UNKNOWN);
@@ -3868,7 +3869,8 @@ PyUnicode_DecodeFSDefaultAndSize(const char *s, Py_ssize_t size)
/* Before _PyUnicode_InitEncodings() is called, the Python codec
machinery is not ready and so cannot be used:
use mbstowcs() in this case. */
- const wchar_t *filesystem_errors = interp->config.filesystem_errors;
+ const PyConfig *config = _PyInterpreterState_GetConfig(interp);
+ const wchar_t *filesystem_errors = config->filesystem_errors;
assert(filesystem_errors != NULL);
_Py_error_handler errors = get_error_handler_wide(filesystem_errors);
assert(errors != _Py_ERROR_UNKNOWN);
@@ -15894,7 +15896,7 @@ static PyStatus
init_stdio_encoding(PyThreadState *tstate)
{
/* Update the stdio encoding to the normalized Python codec name. */
- PyConfig *config = &tstate->interp->config;
+ PyConfig *config = (PyConfig*)_PyInterpreterState_GetConfig(tstate->interp);
if (config_get_codec_name(&config->stdio_encoding) < 0) {
return _PyStatus_ERR("failed to get the Python codec name "
"of the stdio encoding");
@@ -15906,7 +15908,7 @@ init_stdio_encoding(PyThreadState *tstate)
static int
init_fs_codec(PyInterpreterState *interp)
{
- PyConfig *config = &interp->config;
+ const PyConfig *config = _PyInterpreterState_GetConfig(interp);
_Py_error_handler error_handler;
error_handler = get_error_handler_wide(config->filesystem_errors);
@@ -15964,7 +15966,7 @@ init_fs_encoding(PyThreadState *tstate)
/* Update the filesystem encoding to the normalized Python codec name.
For example, replace "ANSI_X3.4-1968" (locale encoding) with "ascii"
(Python codec name). */
- PyConfig *config = &interp->config;
+ PyConfig *config = (PyConfig*)_PyInterpreterState_GetConfig(interp);
if (config_get_codec_name(&config->filesystem_encoding) < 0) {
_Py_DumpPathConfig(tstate);
return _PyStatus_ERR("failed to get the Python codec "
@@ -16008,7 +16010,7 @@ int
_PyUnicode_EnableLegacyWindowsFSEncoding(void)
{
PyInterpreterState *interp = _PyInterpreterState_GET_UNSAFE();
- PyConfig *config = &interp->config;
+ PyConfig *config = (PyConfig *)_PyInterpreterState_GetConfig(interp);
/* Set the filesystem encoding to mbcs/replace (PEP 529) */
wchar_t *encoding = _PyMem_RawWcsdup(L"mbcs");