mirror of
https://github.com/python/cpython.git
synced 2025-07-09 20:35:26 +00:00
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:
parent
de42755674
commit
fbca90856d
6 changed files with 50 additions and 40 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue