summaryrefslogtreecommitdiffstats
path: root/Objects/unicodeobject.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-04-13 01:04:28 (GMT)
committerGitHub <noreply@github.com>2020-04-13 01:04:28 (GMT)
commitda7933ecc30e37b119756cb02b89a6ad99db22e0 (patch)
treee6c7227f2ded7b7354fb027342fa977f70808d10 /Objects/unicodeobject.c
parent14d5331eb5e6c38be12bad421bd59ad0fac9e448 (diff)
downloadcpython-da7933ecc30e37b119756cb02b89a6ad99db22e0.zip
cpython-da7933ecc30e37b119756cb02b89a6ad99db22e0.tar.gz
cpython-da7933ecc30e37b119756cb02b89a6ad99db22e0.tar.bz2
bpo-40268: Add _PyInterpreterState_GetConfig() (GH-19492)
Don't access PyInterpreterState.config member directly anymore, but use new functions: * _PyInterpreterState_GetConfig() * _PyInterpreterState_SetConfig() * _Py_GetConfig()
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r--Objects/unicodeobject.c16
1 files changed, 9 insertions, 7 deletions
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");