summaryrefslogtreecommitdiffstats
path: root/Parser
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-11-06 16:01:48 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2015-11-06 16:01:48 (GMT)
commitc106c68aeb5814583a622587e63504f0c93c5140 (patch)
treeb026a25fd175002dfa1e0cfba6168f7ccfa95b9f /Parser
parent0c009bf3b5c7fdcd2044acb3e8802d5db4bf19d7 (diff)
downloadcpython-c106c68aeb5814583a622587e63504f0c93c5140.zip
cpython-c106c68aeb5814583a622587e63504f0c93c5140.tar.gz
cpython-c106c68aeb5814583a622587e63504f0c93c5140.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')
-rw-r--r--Parser/asdl_c.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py
index 3128078..eedd89b 100644
--- 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)