diff options
author | Batuhan Taskaya <batuhanosmantaskaya@gmail.com> | 2020-05-06 14:29:32 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-06 14:29:32 (GMT) |
commit | 091951a67c832db83c60f4eb22f1fb474b70e635 (patch) | |
tree | 67fa56ccc7099d080ac19460d82a68b7f685b8ff /Parser | |
parent | 2668a9a5aa506a048aef7b4881c8dcf6b81c6870 (diff) | |
download | cpython-091951a67c832db83c60f4eb22f1fb474b70e635.zip cpython-091951a67c832db83c60f4eb22f1fb474b70e635.tar.gz cpython-091951a67c832db83c60f4eb22f1fb474b70e635.tar.bz2 |
bpo-40528: Improve and clear several aspects of the ASDL definition code for the AST (GH-19952)
Diffstat (limited to 'Parser')
-rw-r--r-- | Parser/Python.asdl | 4 | ||||
-rw-r--r-- | Parser/asdl.py | 3 | ||||
-rwxr-xr-x | Parser/asdl_c.py | 10 |
3 files changed, 5 insertions, 12 deletions
diff --git a/Parser/Python.asdl b/Parser/Python.asdl index f789f1d..889712b 100644 --- a/Parser/Python.asdl +++ b/Parser/Python.asdl @@ -1,5 +1,5 @@ --- ASDL's 5 builtin types are: --- identifier, int, string, object, constant +-- ASDL's 4 builtin types are: +-- identifier, int, string, constant module Python { diff --git a/Parser/asdl.py b/Parser/asdl.py index 5416377..7f50948 100644 --- a/Parser/asdl.py +++ b/Parser/asdl.py @@ -33,8 +33,7 @@ __all__ = [ # See the EBNF at the top of the file to understand the logical connection # between the various node types. -builtin_types = {'identifier', 'string', 'bytes', 'int', 'object', 'singleton', - 'constant'} +builtin_types = {'identifier', 'string', 'int', 'constant'} class AST: def __repr__(self): diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py index c98f949..59bf03e 100755 --- a/Parser/asdl_c.py +++ b/Parser/asdl_c.py @@ -323,7 +323,7 @@ class FunctionVisitor(PrototypeVisitor): if not opt and argtype != "int": emit("if (!%s) {" % argname, 1) emit("PyErr_SetString(PyExc_ValueError,", 2) - msg = "field %s is required for %s" % (argname, name) + msg = "field '%s' is required for %s" % (argname, name) emit(' "%s");' % msg, 2, reflow=False) emit('return NULL;', 2) @@ -853,11 +853,9 @@ static PyObject* ast2obj_object(void *o) Py_INCREF((PyObject*)o); return (PyObject*)o; } -#define ast2obj_singleton ast2obj_object #define ast2obj_constant ast2obj_object #define ast2obj_identifier ast2obj_object #define ast2obj_string ast2obj_object -#define ast2obj_bytes ast2obj_object static PyObject* ast2obj_int(long b) { @@ -1147,12 +1145,8 @@ class ObjVisitor(PickleVisitor): self.emit("case %s:" % t.name, 2) self.emit("Py_INCREF(astmodulestate_global->%s_singleton);" % t.name, 3) self.emit("return astmodulestate_global->%s_singleton;" % t.name, 3) - self.emit("default:", 2) - self.emit('/* should never happen, but just in case ... */', 3) - code = "PyErr_Format(PyExc_SystemError, \"unknown %s found\");" % name - self.emit(code, 3, reflow=False) - self.emit("return NULL;", 3) self.emit("}", 1) + self.emit("Py_UNREACHABLE();", 1); self.emit("}", 0) def visitProduct(self, prod, name): |