bpo-34523: Use _PyCoreConfig instead of globals (GH-9005)

Use the core configuration of the interpreter, rather
than using global configuration variables. For example, replace
Py_QuietFlag with core_config->quiet.
This commit is contained in:
Victor Stinner 2018-08-30 00:50:45 +02:00 committed by GitHub
parent de42755674
commit fbca90856d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 50 additions and 40 deletions

View file

@ -2,6 +2,7 @@
#include "Python.h"
#include "Python-ast.h"
#include "internal/pystate.h"
#include "node.h"
#include "code.h"
@ -2765,6 +2766,8 @@ _PyBuiltin_Init(void)
{
PyObject *mod, *dict, *debug;
const _PyCoreConfig *config = &_PyInterpreterState_GET_UNSAFE()->core_config;
if (PyType_Ready(&PyFilter_Type) < 0 ||
PyType_Ready(&PyMap_Type) < 0 ||
PyType_Ready(&PyZip_Type) < 0)
@ -2823,7 +2826,7 @@ _PyBuiltin_Init(void)
SETBUILTIN("tuple", &PyTuple_Type);
SETBUILTIN("type", &PyType_Type);
SETBUILTIN("zip", &PyZip_Type);
debug = PyBool_FromLong(Py_OptimizeFlag == 0);
debug = PyBool_FromLong(config->optimization_level == 0);
if (PyDict_SetItemString(dict, "__debug__", debug) < 0) {
Py_DECREF(debug);
return NULL;