[issue25322] contextlib.suppress not tested for nested usage

Frazer McLean report at bugs.python.org
Tue Oct 6 05:21:46 EDT 2015


New submission from Frazer McLean:

In Lib/test/test_contextlib.py, there is a bug in the nested usage part of the following function:

def test_cm_is_reentrant(self): 
    ignore_exceptions = suppress(Exception) 
    with ignore_exceptions: 
        pass 
    with ignore_exceptions: 
        len(5) 
    with ignore_exceptions: 
        1/0 
        with ignore_exceptions: # Check nested usage 
            len(5)

Specifically, the final 2 lines aren't reached since the exception raised by 1/0 exits the context manager.

----------
components: Tests
messages: 252382
nosy: RazerM, ncoghlan, yselivanov
priority: normal
severity: normal
status: open
title: contextlib.suppress not tested for nested usage
type: behavior
versions: Python 3.4, Python 3.5

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25322>
_______________________________________


More information about the Python-bugs-list mailing list