[Python-bugs-list] [ python-Bugs-607092 ] wrong SET_LINENO w/ multi-line func args

noreply@sourceforge.net noreply@sourceforge.net
Tue, 10 Sep 2002 06:07:56 -0700


Bugs item #607092, was opened at 2002-09-10 02:18
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=607092&group_id=5470

Category: Parser/Compiler
Group: Python 2.2.1
Status: Open
Resolution: None
Priority: 5
Submitted By: Inyeol Lee (inyeol)
>Assigned to: Michael Hudson (mwh)
Summary: wrong SET_LINENO w/ multi-line func args

Initial Comment:
Python 2.2.1 (#1, Apr 10 2002, 18:25:16) 
[GCC 2.95.3 20010315 (release)] on sunos5
Type "help", "copyright", "credits" or "license" for
more information.
>>> import dis
>>> def f():  # line 1
...   a = [1, # line 2
...     2]
...   b = (1, # line 4
...     2)
...   c(1,    # line 6
...     2)
... 
>>> dis.dis(f)
          0 SET_LINENO               1

          3 SET_LINENO               2
          6 LOAD_CONST               1 (1)
          9 LOAD_CONST               2 (2)
         12 BUILD_LIST               2
         15 STORE_FAST               0 (a)

         18 SET_LINENO               4
         21 LOAD_CONST               1 (1)
         24 LOAD_CONST               2 (2)
         27 BUILD_TUPLE              2
         30 STORE_FAST               1 (b)

         33 SET_LINENO               6
         36 LOAD_GLOBAL              2 (c)
         39 LOAD_CONST               1 (1)

         42 SET_LINENO               7              
<-- Error, should not be here.
         45 LOAD_CONST               2 (2)
         48 CALL_FUNCTION            2
         51 POP_TOP             
         52 LOAD_CONST               0 (None)
         55 RETURN_VALUE        
>>> 

python 2.2.1 generates errornous SET_LINENO instruction
when
function arguments tuple is separated by physical, not
logical newline.
This results in errornous frame.f_lineno.

-Inyeol Lee


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

>Comment By: Michael Hudson (mwh)
Date: 2002-09-10 13:07

Message:
Logged In: YES 
user_id=6656

Why is this a problem?

Execution isn't really on line 6 there.  Think about code like:

f()(1,  # line 1
 c())   # line 2

when "c()" is being evaluated, surely frame.f_lineno should
be 2?  do you think it should go back to 1 when the function
f() returns is called?

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

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