Issue1142

classification
Title: nested contextmanager does not catch exception
Type: behaviour Severity: normal
Components: Core Versions: 2.5alpha3
Milestone:
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: ruseel, zyasoft
Priority: Keywords:

Created on 2008-10-02.04:18:42 by ruseel, last changed 2008-10-11.03:20:31 by zyasoft.

Files
File name Uploaded Description Edit Remove
test_contextmanager.py ruseel, 2008-10-02.04:18:41
Messages
msg3633 (view) Author: (ruseel) Date: 2008-10-02.04:18:41
If there is nested contextmanager and try clause does not work as expected

with another_contextmanager():
  try: 
    with some_error_rasing_contextmanager():
      pass
  except:
    print 'catch'

----

enex:src ruseel$ python --version
Python 2.5.1
enex:src ruseel$ python test_contextmanager.py 
catch
.
----------------------------------------------------------------------
Ran 1 test in 0.000s

OK
enex:src ruseel$ jython --version
Jython 2.5a3 (trunk:5315:5317, Sep 10 2008, 20:54:23) 
[Java HotSpot(TM) Client VM (Apple Inc.)] on java1.5.0_13
enex:src ruseel$ jython test_contextmanager.py 
E
======================================================================
ERROR: test_a (__main__.TestContextManager)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test_contextmanager.py", line 0, in test_a
  File "/Users/ruseel/jython2.5a3/Lib/contextlib.py", line 81, in helper
    return GeneratorContextManager(func(*args, **kwds))
  File "test_contextmanager.py", line 7, in some_cm
    raise ValueError('error from some_cm()')
ValueError: error from some_cm()

----------------------------------------------------------------------
Ran 1 test in 0.019s

FAILED (errors=1)
msg3652 (view) Author: Jim Baker (zyasoft) Date: 2008-10-11.03:20:30
This is resolved in trunk as of r5346 and further verified against the
included test.

Nested context managers (like test_contextmanager.py, attached, thanks
this always really helps!) are tested by test_contextlib.py and test_with.py
History
Date User Action Args
2008-10-11 03:20:31zyasoftsetstatus: open -> closed
resolution: out of date
messages: + msg3652
nosy: + zyasoft
2008-10-02 04:18:42ruseelcreate