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:
Victor Stinner 2020-04-13 03:04:28 +02:00 committed by GitHub
parent 14d5331eb5
commit da7933ecc3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 90 additions and 64 deletions

View file

@ -23,7 +23,6 @@
#include "Python.h"
#include "pycore_pystate.h" /* _PyInterpreterState_GET_UNSAFE() */
#include "Python-ast.h"
#include "ast.h"
#include "code.h"
@ -323,7 +322,6 @@ PyAST_CompileObject(mod_ty mod, PyObject *filename, PyCompilerFlags *flags,
PyCodeObject *co = NULL;
PyCompilerFlags local_flags = _PyCompilerFlags_INIT;
int merged;
PyConfig *config = &_PyInterpreterState_GET_UNSAFE()->config;
if (!__doc__) {
__doc__ = PyUnicode_InternFromString("__doc__");
@ -350,7 +348,7 @@ PyAST_CompileObject(mod_ty mod, PyObject *filename, PyCompilerFlags *flags,
c.c_future->ff_features = merged;
flags->cf_flags = merged;
c.c_flags = flags;
c.c_optimize = (optimize == -1) ? config->optimization_level : optimize;
c.c_optimize = (optimize == -1) ? _Py_GetConfig()->optimization_level : optimize;
c.c_nestlevel = 0;
c.c_do_not_emit_bytecode = 0;