@@ -510,8 +510,10 @@ static PyCodeObject *optimize_and_assemble(struct compiler *, int addNone);
510510
511511static int
512512compiler_setup (struct compiler * c , mod_ty mod , PyObject * filename ,
513- PyCompilerFlags flags , int optimize , PyArena * arena )
513+ PyCompilerFlags * flags , int optimize , PyArena * arena )
514514{
515+ PyCompilerFlags local_flags = _PyCompilerFlags_INIT ;
516+
515517 c -> c_const_cache = PyDict_New ();
516518 if (!c -> c_const_cache ) {
517519 return ERROR ;
@@ -527,10 +529,13 @@ compiler_setup(struct compiler *c, mod_ty mod, PyObject *filename,
527529 if (!_PyFuture_FromAST (mod , filename , & c -> c_future )) {
528530 return ERROR ;
529531 }
530- int merged = c -> c_future .ff_features | flags .cf_flags ;
532+ if (!flags ) {
533+ flags = & local_flags ;
534+ }
535+ int merged = c -> c_future .ff_features | flags -> cf_flags ;
531536 c -> c_future .ff_features = merged ;
532- flags . cf_flags = merged ;
533- c -> c_flags = flags ;
537+ flags -> cf_flags = merged ;
538+ c -> c_flags = * flags ;
534539 c -> c_optimize = (optimize == -1 ) ? _Py_GetConfig ()-> optimization_level : optimize ;
535540 c -> c_nestlevel = 0 ;
536541
@@ -555,12 +560,11 @@ static struct compiler*
555560new_compiler (mod_ty mod , PyObject * filename , PyCompilerFlags * pflags ,
556561 int optimize , PyArena * arena )
557562{
558- PyCompilerFlags flags = pflags ? * pflags : _PyCompilerFlags_INIT ;
559563 struct compiler * c = PyMem_Calloc (1 , sizeof (struct compiler ));
560564 if (c == NULL ) {
561565 return NULL ;
562566 }
563- if (compiler_setup (c , mod , filename , flags , optimize , arena ) < 0 ) {
567+ if (compiler_setup (c , mod , filename , pflags , optimize , arena ) < 0 ) {
564568 compiler_free (c );
565569 return NULL ;
566570 }
0 commit comments