diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-11-06 16:01:48 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-11-06 16:01:48 (GMT) |
commit | f9827ea61859c6fb3fdac1e5a364d87bd4237622 (patch) | |
tree | db30660124cf9157baeae6638e2cf13ffa0e28f5 /Parser | |
parent | 82639816df9e2d06fe47687983c13e535895649d (diff) | |
download | cpython-f9827ea61859c6fb3fdac1e5a364d87bd4237622.zip cpython-f9827ea61859c6fb3fdac1e5a364d87bd4237622.tar.gz cpython-f9827ea61859c6fb3fdac1e5a364d87bd4237622.tar.bz2 |
Issue #25555: Fix parser and AST: fill lineno and col_offset of "arg" node when
compiling AST from Python objects.
Diffstat (limited to 'Parser')
-rwxr-xr-x | Parser/asdl_c.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py index 79e834b..f38c253 100755 --- a/Parser/asdl_c.py +++ b/Parser/asdl_c.py @@ -275,7 +275,9 @@ class PrototypeVisitor(EmitVisitor): def visitProduct(self, prod, name): self.emit_function(name, get_c_type(name), - self.get_args(prod.fields), [], union=False) + self.get_args(prod.fields), + self.get_args(prod.attributes), + union=False) class FunctionVisitor(PrototypeVisitor): @@ -329,7 +331,8 @@ class FunctionVisitor(PrototypeVisitor): self.emit(s, depth, reflow) for argtype, argname, opt in args: emit("p->%s = %s;" % (argname, argname), 1) - assert not attrs + for argtype, argname, opt in attrs: + emit("p->%s = %s;" % (argname, argname), 1) class PickleVisitor(EmitVisitor): @@ -452,10 +455,15 @@ class Obj2ModVisitor(PickleVisitor): self.emit("PyObject* tmp = NULL;", 1) for f in prod.fields: self.visitFieldDeclaration(f, name, prod=prod, depth=1) + for a in prod.attributes: + self.visitFieldDeclaration(a, name, prod=prod, depth=1) self.emit("", 0) for f in prod.fields: self.visitField(f, name, prod=prod, depth=1) + for a in prod.attributes: + self.visitField(a, name, prod=prod, depth=1) args = [f.name for f in prod.fields] + args.extend([a.name for a in prod.attributes]) self.emit("*out = %s(%s);" % (name, self.buildArgs(args)), 1) self.emit("return 0;", 1) self.emit("failed:", 0) |