bpo-37253: Add _PyCompilerFlags_INIT macro (GH-14018) · python/cpython@37d66d7

@@ -91,7 +91,7 @@ PyRun_InteractiveLoopFlags(FILE *fp, const char *filename_str, PyCompilerFlags *

9191

{

9292

PyObject *filename, *v;

9393

int ret, err;

94-

PyCompilerFlags local_flags;

94+

PyCompilerFlags local_flags = _PyCompilerFlags_INIT;

9595

int nomem_count = 0;

9696

#ifdef Py_REF_DEBUG

9797

int show_ref_count = _PyInterpreterState_Get()->config.show_ref_count;

@@ -105,8 +105,6 @@ PyRun_InteractiveLoopFlags(FILE *fp, const char *filename_str, PyCompilerFlags *

105105106106

if (flags == NULL) {

107107

flags = &local_flags;

108-

local_flags.cf_flags = 0;

109-

local_flags.cf_feature_version = PY_MINOR_VERSION;

110108

}

111109

v = _PySys_GetObjectId(&PyId_ps1);

112110

if (v == NULL) {

@@ -1283,10 +1281,7 @@ _Py_SourceAsString(PyObject *cmd, const char *funcname, const char *what, PyComp

12831281

struct symtable *

12841282

Py_SymtableStringObject(const char *str, PyObject *filename, int start)

12851283

{

1286-

PyCompilerFlags flags;

1287-1288-

flags.cf_flags = 0;

1289-

flags.cf_feature_version = PY_MINOR_VERSION;

1284+

PyCompilerFlags flags = _PyCompilerFlags_INIT;

12901285

return _Py_SymtableStringObjectFlags(str, filename, start, &flags);

12911286

}

12921287

@@ -1331,7 +1326,7 @@ PyParser_ASTFromStringObject(const char *s, PyObject *filename, int start,

13311326

PyCompilerFlags *flags, PyArena *arena)

13321327

{

13331328

mod_ty mod;

1334-

PyCompilerFlags localflags;

1329+

PyCompilerFlags localflags = _PyCompilerFlags_INIT;

13351330

perrdetail err;

13361331

int iflags = PARSER_FLAGS(flags);

13371332

if (flags && flags->cf_feature_version < 7)

@@ -1341,8 +1336,6 @@ PyParser_ASTFromStringObject(const char *s, PyObject *filename, int start,

13411336

&_PyParser_Grammar, start, &err,

13421337

&iflags);

13431338

if (flags == NULL) {

1344-

localflags.cf_flags = 0;

1345-

localflags.cf_feature_version = PY_MINOR_VERSION;

13461339

flags = &localflags;

13471340

}

13481341

if (n) {

@@ -1379,16 +1372,14 @@ PyParser_ASTFromFileObject(FILE *fp, PyObject *filename, const char* enc,

13791372

PyArena *arena)

13801373

{

13811374

mod_ty mod;

1382-

PyCompilerFlags localflags;

1375+

PyCompilerFlags localflags = _PyCompilerFlags_INIT;

13831376

perrdetail err;

13841377

int iflags = PARSER_FLAGS(flags);

1385137813861379

node *n = PyParser_ParseFileObject(fp, filename, enc,

13871380

&_PyParser_Grammar,

13881381

start, ps1, ps2, &err, &iflags);

13891382

if (flags == NULL) {

1390-

localflags.cf_flags = 0;

1391-

localflags.cf_feature_version = PY_MINOR_VERSION;

13921383

flags = &localflags;

13931384

}

13941385

if (n) {