mirror of
https://github.com/python/cpython
synced 2026-09-29 09:20:29 +03:00
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()
This commit is contained in:
parent
14d5331eb5
commit
da7933ecc3
19 changed files with 90 additions and 64 deletions
|
|
@ -9,7 +9,6 @@
|
|||
|
||||
#define PY_SSIZE_T_CLEAN
|
||||
#include "Python.h"
|
||||
#include "pycore_pystate.h" /* _PyInterpreterState_GET_UNSAFE() */
|
||||
#include "structmember.h"
|
||||
#include "_iomodule.h"
|
||||
|
||||
|
|
@ -377,7 +376,7 @@ _io_open_impl(PyObject *module, PyObject *file, const char *mode,
|
|||
{
|
||||
PyObject *RawIO_class = (PyObject *)&PyFileIO_Type;
|
||||
#ifdef MS_WINDOWS
|
||||
PyConfig *config = &_PyInterpreterState_GET_UNSAFE()->config;
|
||||
const PyConfig *config = _Py_GetConfig();
|
||||
if (!config->legacy_windows_stdio && _PyIO_get_console_type(path_or_fd) != '\0') {
|
||||
RawIO_class = (PyObject *)&PyWindowsConsoleIO_Type;
|
||||
encoding = "utf-8";
|
||||
|
|
|
|||
|
|
@ -287,8 +287,7 @@ iobase_finalize(PyObject *self)
|
|||
shutdown issues). */
|
||||
if (res == NULL) {
|
||||
#ifndef Py_DEBUG
|
||||
const PyConfig *config = &_PyInterpreterState_GET_UNSAFE()->config;
|
||||
if (config->dev_mode) {
|
||||
if (_Py_GetConfig()->dev_mode) {
|
||||
PyErr_WriteUnraisable(self);
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
#define PY_SSIZE_T_CLEAN
|
||||
#include "Python.h"
|
||||
#include "pycore_object.h"
|
||||
#include "pycore_pystate.h"
|
||||
#include "structmember.h"
|
||||
#include "_iomodule.h"
|
||||
|
||||
|
|
@ -996,7 +997,7 @@ io_check_errors(PyObject *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
|
||||
|
|
|
|||
|
|
@ -301,7 +301,7 @@ pymain_run_module(const wchar_t *modname, int set_argv0)
|
|||
|
||||
|
||||
static int
|
||||
pymain_run_file(PyConfig *config, PyCompilerFlags *cf)
|
||||
pymain_run_file(const PyConfig *config, PyCompilerFlags *cf)
|
||||
{
|
||||
const wchar_t *filename = config->run_filename;
|
||||
if (PySys_Audit("cpython.run_file", "u", filename) < 0) {
|
||||
|
|
@ -499,7 +499,7 @@ pymain_run_python(int *exitcode)
|
|||
{
|
||||
PyInterpreterState *interp = _PyInterpreterState_GET_UNSAFE();
|
||||
/* pymain_run_stdin() modify the config */
|
||||
PyConfig *config = &interp->config;
|
||||
PyConfig *config = (PyConfig*)_PyInterpreterState_GetConfig(interp);
|
||||
|
||||
PyObject *main_importer_path = NULL;
|
||||
if (config->run_filename != NULL) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue