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)
commitf9827ea61859c6fb3fdac1e5a364d87bd4237622 (patch)
treedb30660124cf9157baeae6638e2cf13ffa0e28f5 /Parser
parent82639816df9e2d06fe47687983c13e535895649d (diff)
downloadcpython-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-xParser/asdl_c.py12
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)