summaryrefslogtreecommitdiffstats
path: root/Python/bltinmodule.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2019-06-13 00:16:41 (GMT)
committerGitHub <noreply@github.com>2019-06-13 00:16:41 (GMT)
commit37d66d7d4bc7dbac9809d69966a774ebb32563be (patch)
tree510316d9aafcba8dc519e9df877c3f20c7f005f9 /Python/bltinmodule.c
parent2c9b498759f4fc74da82a0a96d059d666fa73f16 (diff)
downloadcpython-37d66d7d4bc7dbac9809d69966a774ebb32563be.zip
cpython-37d66d7d4bc7dbac9809d69966a774ebb32563be.tar.gz
cpython-37d66d7d4bc7dbac9809d69966a774ebb32563be.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.
Diffstat (limited to 'Python/bltinmodule.c')
-rw-r--r--Python/bltinmodule.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index abf807a..c3e3059 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -723,12 +723,11 @@ builtin_compile_impl(PyObject *module, PyObject *source, PyObject *filename,
const char *str;
int compile_mode = -1;
int is_ast;
- PyCompilerFlags cf;
int start[] = {Py_file_input, Py_eval_input, Py_single_input, Py_func_type_input};
PyObject *result;
+ PyCompilerFlags cf = _PyCompilerFlags_INIT;
cf.cf_flags = flags | PyCF_SOURCE_IS_UTF8;
- cf.cf_feature_version = PY_MINOR_VERSION;
if (feature_version >= 0 && (flags & PyCF_ONLY_AST)) {
cf.cf_feature_version = feature_version;
}
@@ -889,7 +888,6 @@ builtin_eval_impl(PyObject *module, PyObject *source, PyObject *globals,
{
PyObject *result, *source_copy;
const char *str;
- PyCompilerFlags cf;
if (locals != Py_None && !PyMapping_Check(locals)) {
PyErr_SetString(PyExc_TypeError, "locals must be a mapping");
@@ -941,8 +939,8 @@ builtin_eval_impl(PyObject *module, PyObject *source, PyObject *globals,
return PyEval_EvalCode(source, globals, locals);
}
+ PyCompilerFlags cf = _PyCompilerFlags_INIT;
cf.cf_flags = PyCF_SOURCE_IS_UTF8;
- cf.cf_feature_version = PY_MINOR_VERSION;
str = _Py_SourceAsString(source, "eval", "string, bytes or code", &cf, &source_copy);
if (str == NULL)
return NULL;
@@ -1032,9 +1030,8 @@ builtin_exec_impl(PyObject *module, PyObject *source, PyObject *globals,
else {
PyObject *source_copy;
const char *str;
- PyCompilerFlags cf;
+ PyCompilerFlags cf = _PyCompilerFlags_INIT;
cf.cf_flags = PyCF_SOURCE_IS_UTF8;
- cf.cf_feature_version = PY_MINOR_VERSION;
str = _Py_SourceAsString(source, "exec",
"string, bytes or code", &cf,
&source_copy);