Xavier de Gaye added the comment:

This is an artefact that occurs as the result of raising an exception in the 
local trace function.

Disassembling the first case of failure of as_context.py with the attached 
script gives the following:

  9           0 LOAD_GLOBAL              0 (context)
              3 CALL_FUNCTION            0 (0 positional, 0 keyword pair)
              6 SETUP_WITH              20 (to 29)

 10           9 STORE_FAST               0 (two)

 11          12 LOAD_GLOBAL              1 (print)
             15 LOAD_CONST               1 ('two')
             18 LOAD_FAST                0 (two)
             21 CALL_FUNCTION            2 (2 positional, 0 keyword pair)
             24 POP_TOP
             25 POP_BLOCK
             26 LOAD_CONST               0 (None)
        >>   29 WITH_CLEANUP
             30 END_FINALLY

 12          31 LOAD_GLOBAL              1 (print)
             34 LOAD_CONST               2 ('TWO')
             37 LOAD_FAST                0 (two)
             40 CALL_FUNCTION            2 (2 positional, 0 keyword pair)
             43 POP_TOP
             44 LOAD_CONST               0 (None)
             47 RETURN_VALUE

The __raise() local trace function is invoked on line 10 upon executing the 
STORE_FAST bytecode (this can be confirmed by running foo() under the control 
of pdb).  The exception raised by __raise() causes the assignement to 'two' to 
fail, hence the tracebacks in as_context.py.  This does not seem to be a bug in 
python.

----------
nosy: +xdegaye
Added file: http://bugs.python.org/file40922/as_context_dis.py

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue25474>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to