summaryrefslogtreecommitdiff
path: root/Python/Python-ast.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2019-02-20 18:08:23 -0800
committerGuido van Rossum <guido@python.org>2019-03-05 11:36:11 -0800
commit0e2403f2f95a21912972422564de37cbe129c195 (patch)
tree82d360e7f4c9ea6e2d385c86bf11154de713b717 /Python/Python-ast.c
parentd8b3a98c9098c66a714fd5593e1928af0ffbc631 (diff)
downloadcpython-git-0e2403f2f95a21912972422564de37cbe129c195.tar.gz
Work towards feature_version support
Visible behavior: - Issue error for `X @ Y` (matrix multiply) if c_feature_version < 5 - Add optional feature_version kw arg to ast.parse() (default -1 which implies PY_MINOR_VERSION) - Add feature_version: int = -1 to compile() (via Argument Clinic); this sets cf_feature_version to the given value if >= 0, else defaults to PY_MINOR_VERSION Implementation: - Add PyAST_obj2mod_ex(): like PyAST_obj2mod() but with feature_version arg; the latter calls the former with PY_MINOR_VERSION - Add cf_feature_version to PyCompilerFlags structure; initialized to PY_MINOR_VERSION everywhere - Add c_feature_version to struct compiling; initialize from cf_feature_version - Add 'c' argument to get_operator() - In builtin eval() and exec(), default to PY_MINOR_VERSION TODO: - Put version-dependent ASYNC/AWAIT keyword scanning back - Reject async functions, await expressions, and async for/with in minor versions < 5 - Reject async comprehensions in minor versions < 6 - Reject underscores in numeric literals in minor versions < 6 - Reject variable annotations in minor versions < 6 - Reject `X @= Y` in minor versions < 5
Diffstat (limited to 'Python/Python-ast.c')
-rw-r--r--Python/Python-ast.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/Python/Python-ast.c b/Python/Python-ast.c
index 92ec157571..0411f9f07f 100644
--- a/Python/Python-ast.c
+++ b/Python/Python-ast.c
@@ -8900,6 +8900,11 @@ PyObject* PyAST_mod2obj(mod_ty t)
/* mode is 0 for "exec", 1 for "eval" and 2 for "single" input */
mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode)
{
+ return PyAST_obj2mod_ex(ast, arena, mode, PY_MINOR_VERSION);
+}
+
+mod_ty PyAST_obj2mod_ex(PyObject* ast, PyArena* arena, int mode, int feature_version)
+{
mod_ty res;
PyObject *req_type[3];
char *req_name[] = {"Module", "Expression", "Interactive"};