summaryrefslogtreecommitdiffstats
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-06-13 00:36:03 (GMT)
committerGitHub <noreply@github.com>2019-06-13 00:36:03 (GMT)
commit92e836c7dcaf74f7b8617250414224d24d1eb1f2 (patch)
tree7744c1464030566c890df9b5fba0d1f6282f0ac8 /Python/pythonrun.c
parentc15a682603a47f5aef5025f6a2e3babb699273d6 (diff)
downloadcpython-92e836c7dcaf74f7b8617250414224d24d1eb1f2.zip
cpython-92e836c7dcaf74f7b8617250414224d24d1eb1f2.tar.gz
cpython-92e836c7dcaf74f7b8617250414224d24d1eb1f2.tar.bz2
bpo-37253: Add _PyCompilerFlags_INIT macro (GH-14018)
Add a new _PyCompilerFlags_INIT macro to initialize PyCompilerFlags variables, rather than initializing cf_flags and cf_feature_version explicitly in each variable. (cherry picked from commit 37d66d7d4bc7dbac9809d69966a774ebb32563be) Co-authored-by: Victor Stinner <vstinner@redhat.com>
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r--Python/pythonrun.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 784c15b..8f3ee19 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -91,7 +91,7 @@ PyRun_InteractiveLoopFlags(FILE *fp, const char *filename_str, PyCompilerFlags *
{
PyObject *filename, *v;
int ret, err;
- PyCompilerFlags local_flags;
+ PyCompilerFlags local_flags = _PyCompilerFlags_INIT;
int nomem_count = 0;
#ifdef Py_REF_DEBUG
int show_ref_count = _PyInterpreterState_Get()->config.show_ref_count;
@@ -105,8 +105,6 @@ PyRun_InteractiveLoopFlags(FILE *fp, const char *filename_str, PyCompilerFlags *
if (flags == NULL) {
flags = &local_flags;
- local_flags.cf_flags = 0;
- local_flags.cf_feature_version = PY_MINOR_VERSION;
}
v = _PySys_GetObjectId(&PyId_ps1);
if (v == NULL) {
@@ -1283,10 +1281,7 @@ _Py_SourceAsString(PyObject *cmd, const char *funcname, const char *what, PyComp
struct symtable *
Py_SymtableStringObject(const char *str, PyObject *filename, int start)
{
- PyCompilerFlags flags;
-
- flags.cf_flags = 0;
- flags.cf_feature_version = PY_MINOR_VERSION;
+ PyCompilerFlags flags = _PyCompilerFlags_INIT;
return _Py_SymtableStringObjectFlags(str, filename, start, &flags);
}
@@ -1331,7 +1326,7 @@ PyParser_ASTFromStringObject(const char *s, PyObject *filename, int start,
PyCompilerFlags *flags, PyArena *arena)
{
mod_ty mod;
- PyCompilerFlags localflags;
+ PyCompilerFlags localflags = _PyCompilerFlags_INIT;
perrdetail err;
int iflags = PARSER_FLAGS(flags);
if (flags && flags->cf_feature_version < 7)
@@ -1341,8 +1336,6 @@ PyParser_ASTFromStringObject(const char *s, PyObject *filename, int start,
&_PyParser_Grammar, start, &err,
&iflags);
if (flags == NULL) {
- localflags.cf_flags = 0;
- localflags.cf_feature_version = PY_MINOR_VERSION;
flags = &localflags;
}
if (n) {
@@ -1379,7 +1372,7 @@ PyParser_ASTFromFileObject(FILE *fp, PyObject *filename, const char* enc,
PyArena *arena)
{
mod_ty mod;
- PyCompilerFlags localflags;
+ PyCompilerFlags localflags = _PyCompilerFlags_INIT;
perrdetail err;
int iflags = PARSER_FLAGS(flags);
@@ -1387,8 +1380,6 @@ PyParser_ASTFromFileObject(FILE *fp, PyObject *filename, const char* enc,
&_PyParser_Grammar,
start, ps1, ps2, &err, &iflags);
if (flags == NULL) {
- localflags.cf_flags = 0;
- localflags.cf_feature_version = PY_MINOR_VERSION;
flags = &localflags;
}
if (n) {