diff options
author | Thomas Wouters <thomas@python.org> | 2023-06-20 13:32:39 (GMT) |
---|---|---|
committer | Thomas Wouters <thomas@python.org> | 2023-06-20 13:32:39 (GMT) |
commit | e149448595d9099d54a4f4603e6dd3864e81b6b8 (patch) | |
tree | 3e3cc5fcff73f0ee687af04864dacaa244fcf68a /Python/compile.c | |
parent | e904c35c315a20de97b59f146da3d47402c029da (diff) | |
parent | 164fa930011c46d3261538c17f8c4ffbeedc0f7e (diff) | |
download | cpython-e149448595d9099d54a4f4603e6dd3864e81b6b8.zip cpython-e149448595d9099d54a4f4603e6dd3864e81b6b8.tar.gz cpython-e149448595d9099d54a4f4603e6dd3864e81b6b8.tar.bz2 |
Merge branch '3.12' of https://github.com/python/cpython into 3.12
Diffstat (limited to 'Python/compile.c')
-rw-r--r-- | Python/compile.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/Python/compile.c b/Python/compile.c index f593e95..a8d0016 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -510,8 +510,10 @@ static PyCodeObject *optimize_and_assemble(struct compiler *, int addNone); static int compiler_setup(struct compiler *c, mod_ty mod, PyObject *filename, - PyCompilerFlags flags, int optimize, PyArena *arena) + PyCompilerFlags *flags, int optimize, PyArena *arena) { + PyCompilerFlags local_flags = _PyCompilerFlags_INIT; + c->c_const_cache = PyDict_New(); if (!c->c_const_cache) { return ERROR; @@ -527,10 +529,13 @@ compiler_setup(struct compiler *c, mod_ty mod, PyObject *filename, if (!_PyFuture_FromAST(mod, filename, &c->c_future)) { return ERROR; } - int merged = c->c_future.ff_features | flags.cf_flags; + if (!flags) { + flags = &local_flags; + } + int merged = c->c_future.ff_features | flags->cf_flags; c->c_future.ff_features = merged; - flags.cf_flags = merged; - c->c_flags = flags; + flags->cf_flags = merged; + c->c_flags = *flags; c->c_optimize = (optimize == -1) ? _Py_GetConfig()->optimization_level : optimize; c->c_nestlevel = 0; @@ -555,12 +560,11 @@ static struct compiler* new_compiler(mod_ty mod, PyObject *filename, PyCompilerFlags *pflags, int optimize, PyArena *arena) { - PyCompilerFlags flags = pflags ? *pflags : _PyCompilerFlags_INIT; struct compiler *c = PyMem_Calloc(1, sizeof(struct compiler)); if (c == NULL) { return NULL; } - if (compiler_setup(c, mod, filename, flags, optimize, arena) < 0) { + if (compiler_setup(c, mod, filename, pflags, optimize, arena) < 0) { compiler_free(c); return NULL; } |