[ python-Bugs-1512814 ] Incorrect lineno's in code objects

SourceForge.net noreply at sourceforge.net
Mon Jun 26 18:01:55 CEST 2006


Bugs item #1512814, was opened at 2006-06-26 18:01
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1512814&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Parser/Compiler
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Submitted By: Thomas Wouters (twouters)
Assigned to: Jeremy Hylton (jhylton)
Summary: Incorrect lineno's in code objects

Initial Comment:
The 2.5 compiler forgets how to count linenumbers in
certain situations:

>>> s255 = "".join(["\n"] * 255 + ["spam"])
>>> s256 = "".join(["\n"] * 256 + ["spam"])

>>> exec s255
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 256, in <module>
NameError: name 'spam' is not defined

>>> exec s256
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 1, in <module>
NameError: name 'spam' is not defined

Notice the 'line 1' linenumber in the case of 256 blank
lines. The same happens for 'pass' statements or 'if 0'
blocks instead of blank lines. The problem is in the
actual code objects created:

>>> dis.disco(compile(s255, "", "exec"))
256           0 LOAD_NAME                0 (spam)
              3 POP_TOP             
              4 LOAD_CONST               0 (None)
              7 RETURN_VALUE        
>>> dis.disco(compile(s256, "", "exec"))
  1           0 LOAD_NAME                0 (spam)
              3 POP_TOP             
              4 LOAD_CONST               0 (None)
              7 RETURN_VALUE        



----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1512814&group_id=5470


More information about the Python-bugs-list mailing list