Title: lineno and col_offset attributes of _ast.arg objects are not set
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.4
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: larry Nosy List: Claudiu.Popa, benjamin.peterson, larry, python-dev, vstinner
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):
  from ast import parse
  import tracemalloc
  node = parse(data)
  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 (vstinner) * (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 "", 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)
msg211238 - (view) Author: STINNER Victor (vstinner) * (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 (vstinner) * (Python committer) Date: 2014-02-15 08:15
Ok, thanks for the fix.
msg211498 - (view) Author: STINNER Victor (vstinner) * (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)
Date User Action Args
2014-03-17 06:30:42python-devsetmessages: + msg213796
2014-02-18 09:08:04vstinnersetstatus: 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:39vstinnersettitle: 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:31vstinnersetmessages: + msg211263
2014-02-14 20:30:03benjamin.petersonsetmessages: + msg211239
2014-02-14 20:09:25vstinnersetmessages: + msg211238
2014-02-14 00:22:27python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg211192

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

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