summaryrefslogtreecommitdiffstats
path: root/Parser/pegen.c
diff options
context:
space:
mode:
authorPablo Galindo Salgado <Pablogsal@gmail.com>2021-07-27 16:19:22 (GMT)
committerGitHub <noreply@github.com>2021-07-27 16:19:22 (GMT)
commit6948964ecf94e858448dd28eea634317226d2913 (patch)
tree31cf0a4e617bbf2a8d1edbac809b9b494da9b980 /Parser/pegen.c
parent2f54fbafa6481fb10528cb1d3d6b517ca2a4647f (diff)
downloadcpython-6948964ecf94e858448dd28eea634317226d2913.zip
cpython-6948964ecf94e858448dd28eea634317226d2913.tar.gz
cpython-6948964ecf94e858448dd28eea634317226d2913.tar.bz2
bpo-34013: Generalize the invalid legacy statement error message (GH-27389)
Diffstat (limited to 'Parser/pegen.c')
-rw-r--r--Parser/pegen.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/Parser/pegen.c b/Parser/pegen.c
index 106dba9..f697f00 100644
--- a/Parser/pegen.c
+++ b/Parser/pegen.c
@@ -77,6 +77,18 @@ _PyPegen_check_barry_as_flufl(Parser *p, Token* t) {
return 0;
}
+int
+_PyPegen_check_legacy_stmt(Parser *p, expr_ty name) {
+ assert(name->kind == Name_kind);
+ const char* candidates[2] = {"print", "exec"};
+ for (int i=0; i<2; i++) {
+ if (PyUnicode_CompareWithASCIIString(name->v.Name.id, candidates[i]) == 0) {
+ return 1;
+ }
+ }
+ return 0;
+}
+
PyObject *
_PyPegen_new_identifier(Parser *p, const char *n)
{