[Python-bugs-list] [ python-Bugs-430991 ] wrong co_lnotab

noreply@sourceforge.net noreply@sourceforge.net
Sat, 09 Jun 2001 02:13:00 -0700


Bugs item #430991, was updated on 2001-06-07 03:44
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=430991&group_id=5470

Category: Parser/Compiler
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Armin Rigo (arigo)
>Assigned to: Tim Peters (tim_one)
Summary: wrong co_lnotab

Initial Comment:
The compiler produces a buggy co_lnotab in code objects
if a single source line produces more than 255 bytes of
bytecode. This can lead to tracebacks pointing to wrong
source lines in "python -O".

For example, to emit the information "266 bytes of
bytecode, next line is 5 source code lines below", it
writes in co_lnotab

  255 5 11 0

althought it should write

  255 0 11 5

Because of this an exception occurring in the last 11
bytes of code will be incorrectly reported 5 lines
below. The problem is even more confusing if the number
of lines to skip is itself larger than 255 (see
attached example file).

Fix: in compile.c correct the function com_set_lineno
by replacing the inner while loop with the following :

while (incr_addr > 255) {
    com_add_lnotab(c, 255, 0);
    incr_addr -= 255;
}
while (incr_line > 255) {
    com_add_lnotab(c, incr_addr, 255);
    incr_line -= 255;
    incr_addr = 0;
}
if (incr_line > 0 || incr_addr > 0) {
    com_add_lnotab(c, incr_addr, incr_line);
}


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

>Comment By: Tim Peters (tim_one)
Date: 2001-06-09 02:13

Message:
Logged In: YES 
user_id=31435

Assigned to me.  Good eye!  I agree with your analysis.

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

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