classification
Title: _ast py3k : add lineno back to "args" node
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.2, Python 3.3, Python 3.4
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: Claudiu.Popa, benjamin.peterson, emile.anclin, ncoghlan
Priority: normal Keywords:

Created on 2010-11-17 14:15 by emile.anclin, last changed 2014-06-28 14:12 by Claudiu.Popa. This issue is now closed.

Messages (3)
msg121357 - (view) Author: Emile Anclin (emile.anclin) Date: 2010-11-17 14:15
For Python3x, in the tree generated by _ast, for the "args" node (representing an argument of a function), the "lineno" (and the "col_offset") information disappeared from those nodes.

It would be nice to have them back (for instance for Pylint)
msg220342 - (view) Author: PCManticore (Claudiu.Popa) * (Python triager) Date: 2014-06-12 12:08
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
>>>
msg221791 - (view) Author: PCManticore (Claudiu.Popa) * (Python triager) Date: 2014-06-28 14:12
It seems that this was actual the case for Python 3.2 and 3.3, but fixed in 3.4. Unfortunately, it's too late now to add those fields back, since 3.2 and 3.3 receives only security updates. So I guess this issue can be closed.
History
Date User Action Args
2014-06-28 14:12:10Claudiu.Popasetstatus: open -> closed
resolution: out of date
messages: + msg221791

stage: needs patch -> resolved
2014-06-12 12:08:52Claudiu.Popasettype: resource usage -> behavior

messages: + msg220342
nosy: + Claudiu.Popa
2012-09-11 22:53:48ezio.melottisetnosy: + ncoghlan
stage: needs patch

components: + Interpreter Core, - None
versions: + Python 3.3, Python 3.4
2010-11-21 03:13:59eric.araujosetnosy: + benjamin.peterson
2010-11-17 14:15:24emile.anclincreate