[issue10445] _ast py3k : add lineno back to "args" node

Claudiu.Popa report at bugs.python.org
Thu Jun 12 14:08:52 CEST 2014


Claudiu.Popa added the comment:

This doesn't seem to be the case for Python 3.4. Also, _ast.arguments didn't have "lineno" and "col_offset" attributes neither in Python 2. But the _arg.arg nodes have those attributes, as seen in this example.

>>> from ast import parse
>>> parse("""
... def test(a): pass
... """)
<_ast.Module object at 0x02E43330>
>>> f=_
>>> f.body[0].args
<_ast.arguments object at 0x02E43390>
>>> f.body[0].args.lineno
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'arguments' object has no attribute 'lineno'
>>> f.body[0].args.args
[<_ast.arg object at 0x02E43270>]
>>> f.body[0].args.args[0].lineno
2
>>>

----------
nosy: +Claudiu.Popa
type: resource usage -> behavior

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10445>
_______________________________________


More information about the Python-bugs-list mailing list