int cf_flags; /* bitmask of CO_xxx flags relevant to future */
int cf_feature_version; /* minor Python version (PyCF_ONLY_AST) */
} PyCompilerFlags;
+
+#define _PyCompilerFlags_INIT \
+ (PyCompilerFlags){.cf_flags = 0, .cf_feature_version = PY_MINOR_VERSION}
#endif
/* Future feature support */
}
}
- PyCompilerFlags cf = {.cf_flags = 0, .cf_feature_version = PY_MINOR_VERSION};
+ PyCompilerFlags cf = _PyCompilerFlags_INIT;
pymain_header(config);
pymain_import_readline(config);
if (o != 0) {
o->st_node = st;
o->st_type = type;
- o->st_flags.cf_flags = 0;
- o->st_flags.cf_feature_version = PY_MINOR_VERSION;
+ o->st_flags = _PyCompilerFlags_INIT;
}
else {
PyNode_Free(st);
struct symtable *st;
PyObject *t;
int start;
- PyCompilerFlags cf;
+ PyCompilerFlags cf = _PyCompilerFlags_INIT;
PyObject *source_copy = NULL;
cf.cf_flags = PyCF_SOURCE_IS_UTF8;
- cf.cf_feature_version = PY_MINOR_VERSION;
const char *str = _Py_SourceAsString(source, "symtable", "string or bytes", &cf, &source_copy);
if (str == NULL) {
struct compiling *c, const node *n)
{
- PyCompilerFlags cf;
node *mod_n;
mod_ty mod;
char *str;
str[len+1] = ')';
str[len+2] = 0;
+ PyCompilerFlags cf = _PyCompilerFlags_INIT;
cf.cf_flags = PyCF_ONLY_AST;
- cf.cf_feature_version = PY_MINOR_VERSION;
mod_n = PyParser_SimpleParseStringFlagsFilename(str, "<fstring>",
Py_eval_input, 0);
if (!mod_n) {
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;
}
{
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");
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;
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);
{
struct compiler c;
PyCodeObject *co = NULL;
- PyCompilerFlags local_flags;
+ PyCompilerFlags local_flags = _PyCompilerFlags_INIT;
int merged;
PyConfig *config = &_PyInterpreterState_GET_UNSAFE()->config;
if (c.c_future == NULL)
goto finally;
if (!flags) {
- local_flags.cf_flags = 0;
- local_flags.cf_feature_version = PY_MINOR_VERSION;
flags = &local_flags;
}
merged = c.c_future->ff_features | flags->cf_flags;
{
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;
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) {
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);
}
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)
&_PyParser_Grammar, start, &err,
&iflags);
if (flags == NULL) {
- localflags.cf_flags = 0;
- localflags.cf_feature_version = PY_MINOR_VERSION;
flags = &localflags;
}
if (n) {
PyArena *arena)
{
mod_ty mod;
- PyCompilerFlags localflags;
+ PyCompilerFlags localflags = _PyCompilerFlags_INIT;
perrdetail err;
int iflags = PARSER_FLAGS(flags);
&_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) {