classification
Title: lineno and col_offset attributes of _ast.arg objects are not set
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: larry Nosy List: Claudiu.Popa, benjamin.peterson, haypo, larry, python-dev
Priority: release blocker Keywords:

Created on 2014-02-13 20:00 by Claudiu.Popa, last changed 2014-03-17 06:30 by python-dev. This issue is now closed.

Messages (9)
msg211165 - (view) Author: Claudiu Popa (Claudiu.Popa) * Date: 2014-02-13 20:00
Here's a strange bug. I don't know if this is legitimate or not, but it seems like there is some sort of overflow.

Given the following code:

  data = """
  def function(*, foot):
    print(foot)
  """
  from ast import parse
  import tracemalloc
  tracemalloc.start()
  node = parse(data)
  tracemalloc.stop()
  arg = node.body[0].args.kwonlyargs[0]
  print(arg.lineno, arg.col_offset)

it yields on a freshly build the following, which is obviously wrong. It should have printed `1 1`.

  <_ast.arg object at 0x80103bcf8>
  1681660160 -2124152704

Also, there is no need to call tracemalloc.start, it has the same behaviour just by importing it.
msg211166 - (view) Author: Claudiu Popa (Claudiu.Popa) * Date: 2014-02-13 20:03
The version of the interpreter is:

Python 3.4.0rc1+ (default:1166b3321012, Feb 13 2014, 21:49:27)
[GCC 4.2.1 20070831 patched [FreeBSD]] on freebsd8
msg211177 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2014-02-13 21:55
I don't understand the link with tracemalloc. I get the same result if I comment all lines containing tracemalloc.

With Python 3.3, I get:

Traceback (most recent call last):
  File "x.py", line 9, in <module>
    print(arg.lineno, arg.col_offset)
AttributeError: 'arg' object has no attribute 'lineno'

With Python 3.4, I get a number which looks random, but lineno and col_offset have the same value.

I'm not sure if it's a regression or not, so I set the priority to release blocker.
msg211192 - (view) Author: Roundup Robot (python-dev) Date: 2014-02-14 00:22
New changeset 2dd4922c9371 by Benjamin Peterson in branch 'default':
set line and column numbers for keyword-only arg nodes (closes #20619)
http://hg.python.org/cpython/rev/2dd4922c9371
msg211238 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2014-02-14 20:09
The fix should not be backported?
msg211239 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2014-02-14 20:30
This is a 3.4 only issue.
msg211263 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2014-02-15 08:15
Ok, thanks for the fix.
msg211498 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2014-02-18 09:08
I created #20670 to ask to add it to 3.4.0 RC2.
msg213796 - (view) Author: Roundup Robot (python-dev) Date: 2014-03-17 06:30
New changeset 3c01209ab697 by Benjamin Peterson in branch '3.4':
set line and column numbers for keyword-only arg nodes (closes #20619)
http://hg.python.org/cpython/rev/3c01209ab697
History
Date User Action Args
2014-03-17 06:30:42python-devsetmessages: + msg213796
2014-02-18 09:08:04hayposetstatus: open -> closed
resolution: fixed
messages: + msg211498
2014-02-17 16:41:01benjamin.petersonsetstatus: closed -> open
assignee: larry
resolution: fixed -> (no value)
2014-02-15 08:16:39hayposettitle: tracemalloc changes col_offset attribute for _ast.arg objects -> lineno and col_offset attributes of _ast.arg objects are not set
2014-02-15 08:15:31hayposetmessages: + msg211263
2014-02-14 20:30:03benjamin.petersonsetmessages: + msg211239
2014-02-14 20:09:25hayposetmessages: + msg211238
2014-02-14 00:22:27python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg211192

resolution: fixed
stage: resolved
2014-02-13 21:55:47hayposetpriority: normal -> release blocker
nosy: + larry, benjamin.peterson
messages: + msg211177

2014-02-13 20:03:11Claudiu.Popasetnosy: + haypo
messages: + msg211166
2014-02-13 20:00:24Claudiu.Popacreate