[ python-Bugs-1246473 ] line numbers off by 1 in dis

SourceForge.net noreply at sourceforge.net
Thu Jul 28 07:25:51 CEST 2005


Bugs item #1246473, was opened at 2005-07-27 19:18
Message generated for change (Comment added) made by bcannon
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1246473&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: AST
Status: Open
Resolution: None
Priority: 5
Submitted By: Brett Cannon (bcannon)
Assigned to: Nobody/Anonymous (nobody)
Summary: line numbers off by 1 in dis

Initial Comment:
test_dis.py:test_dis is failing for two reasons: the
line numbers are off by one (need to be bumped up) and
the peepholer is not being used and thus the
LOAD_CONST(None);RETURN_VALUE idiom is still being
tacked on to everything.

The former problem needs to be fixed while the latter
is not an issue and thus the test needs to get tweaked
to allow for the return.

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

>Comment By: Brett Cannon (bcannon)
Date: 2005-07-27 22:25

Message:
Logged In: YES 
user_id=357491

I don't think this last problem is easily fixed.  If you
look at the AST, only statements have a lineno attribute. 
But it is an expression that is on another line from the
main line of the statement.  I cannot think of any way to
get the line information from the statement without adding a
lineno attribute to expressions and removing it from
statements.  That should give the coverage needed to know
when another line is being outputted.

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

Comment By: Brett Cannon (bcannon)
Date: 2005-07-27 20:59

Message:
Logged In: YES 
user_id=357491

I have test_dis now passing thanks to some refactoring to
handle the initial line.  Now I just need to try to fix
test_bug_708901.

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

Comment By: Brett Cannon (bcannon)
Date: 2005-07-27 19:40

Message:
Logged In: YES 
user_id=357491

OK, so first oddity; in both Python 2.5 and the AST branch
co_firstlineno, when working on a function at the
interpreter prompt, is set to 1.  But if you look at
co_lnotab, AST has '\x05\x01' while 2.5 has
'\x00\x01\x05\x01'.  If you tack on another line to the test
function, AST has '\x05\x01\x05\x01' while 2.5 has
'\x00\x01\x05\x01\x05\x01'.

The critical thing is the initial '\x00\x01'.  Looks like
2.5 tacks that on or somehow decides it needs to state the
initial line at 0 is a byte long.

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

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


More information about the Python-bugs-list mailing list