gh-105908: fix barry_as_FLUFL future import (#105909)

This commit is contained in:
Crowthebird 2023-06-20 05:50:57 +08:00 committed by GitHub
parent 1858db7cbd
commit 28187a9c4f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 6 deletions

View file

@ -494,8 +494,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;
@ -511,10 +513,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;
@ -535,12 +540,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;
}