diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2006-04-04 04:00:23 (GMT) |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2006-04-04 04:00:23 (GMT) |
commit | 2f327c14eb998e8796a3775aa6a7aade14e97004 (patch) | |
tree | 3de98142ca2b873c0cfb25f630c7dda2d90f96fa /Parser | |
parent | cb30f97bd3bdea2e884e8faec23751b39db4c0b3 (diff) | |
download | cpython-2f327c14eb998e8796a3775aa6a7aade14e97004.zip cpython-2f327c14eb998e8796a3775aa6a7aade14e97004.tar.gz cpython-2f327c14eb998e8796a3775aa6a7aade14e97004.tar.bz2 |
Add lineno, col_offset to excephandler to enable future fix for
tracing/line number table in except blocks.
Reflow long lines introduced by col_offset changes. Update test_ast
to handle new fields in excepthandler.
As note in Python.asdl says, we might want to rethink how attributes
are handled. Perhaps they should be the same as other fields, with
the primary difference being how they are defined for all types within
a sum.
Also fix asdl_c so that constructors with int fields don't fail when
passed a zero value.
Diffstat (limited to 'Parser')
-rw-r--r-- | Parser/Python.asdl | 7 | ||||
-rwxr-xr-x | Parser/asdl_c.py | 2 |
2 files changed, 6 insertions, 3 deletions
diff --git a/Parser/Python.asdl b/Parser/Python.asdl index 4397d89..00de381 100644 --- a/Parser/Python.asdl +++ b/Parser/Python.asdl @@ -98,8 +98,11 @@ module Python version "$Revision$" comprehension = (expr target, expr iter, expr* ifs) -- not sure what to call the first argument for raise and except - - excepthandler = (expr? type, expr? name, stmt* body) + -- TODO(jhylton): Figure out if there is a better way to handle + -- lineno and col_offset fields, particularly when + -- ast is exposed to Python. + excepthandler = (expr? type, expr? name, stmt* body, int lineno, + int col_offset) arguments = (expr* args, identifier? vararg, identifier? kwarg, expr* defaults) diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py index bc59c38..5bb42ec 100755 --- a/Parser/asdl_c.py +++ b/Parser/asdl_c.py @@ -276,7 +276,7 @@ class FunctionVisitor(PrototypeVisitor): emit("%s p;" % ctype, 1) for argtype, argname, opt in args: # XXX hack alert: false is allowed for a bool - if not opt and not argtype == "bool": + if not opt and not (argtype == "bool" or argtype == "int"): emit("if (!%s) {" % argname, 1) emit("PyErr_SetString(PyExc_ValueError,", 2) msg = "field %s is required for %s" % (argname, name) |