[issue34372] Compiler could output more accurate line numbers

Ammar Askar report at bugs.python.org
Wed Aug 15 03:45:04 EDT 2018


Ammar Askar <ammar at ammaraskar.com> added the comment:

Note that even just adding an extra arithmetic in your first expression breaks the line numbers:

>>> code = """(                                    
... [                                              
...   call1(),                                     
...   call2()                                      
... ]                                              
... + call3()                                      
... * call4()                                      
... + call5()                                      
... )"""                                           
>>> dis.dis(code)                                  
  8           0 LOAD_NAME                0 (call1) 
              2 CALL_FUNCTION            0         
              4 LOAD_NAME                1 (call2) 
              6 CALL_FUNCTION            0         
              8 BUILD_LIST               2         
             10 LOAD_NAME                2 (call3) 
             12 CALL_FUNCTION            0         
             14 LOAD_NAME                3 (call4) 
             16 CALL_FUNCTION            0         
             18 BINARY_MULTIPLY                    
             20 BINARY_ADD                         
             22 LOAD_NAME                4 (call5) 
             24 CALL_FUNCTION            0         
             26 BINARY_ADD                         
             28 RETURN_VALUE                       

The closest existing bug to this would be issue 12458, specifically with Serhiy's last comment.

----------
nosy: +ammar2

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34372>
_______________________________________


More information about the Python-bugs-list mailing list