[issue25322] contextlib.suppress not tested for nested usage

2015-10-10 Thread R. David Murray

R. David Murray added the comment:

I had no problem understanding that ignored meant the exception had been 
ignored, but making it clearer certainly doesn't hurt.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25322] contextlib.suppress not tested for nested usage

2015-10-10 Thread Martin Panter

Martin Panter added the comment:

Okay maybe “ignored” wasn’t the best choice of variable name. Perhaps I will 
write “outer_continued = True” instead.

--
assignee:  -> martin.panter
nosy: +berker.peksag
stage:  -> commit review
versions: +Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25322] contextlib.suppress not tested for nested usage

2015-10-10 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 452f76cbebdd by Martin Panter in branch '3.4':
Issue #25322: Fix test for nested contextlib.suppress
https://hg.python.org/cpython/rev/452f76cbebdd

New changeset 836ac579e179 by Martin Panter in branch '3.5':
Issue #25322: Merge contextlib.suppress test fix from 3.4 into 3.5
https://hg.python.org/cpython/rev/836ac579e179

New changeset c601496c2829 by Martin Panter in branch 'default':
Issue #25322: Merge contextlib.suppress test fix from 3.5
https://hg.python.org/cpython/rev/c601496c2829

--
nosy: +python-dev

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25322] contextlib.suppress not tested for nested usage

2015-10-10 Thread Martin Panter

Changes by Martin Panter :


--
resolution:  -> fixed
stage: commit review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25322] contextlib.suppress not tested for nested usage

2015-10-07 Thread Nan Wu

Nan Wu added the comment:

Added a patch with Martina's idea. Isn't ignored better set as false instead ? 
Since interpreter did not ignore it.

--
keywords: +patch
nosy: +Nan Wu
Added file: http://bugs.python.org/file40713/fix_reentrant_cm_test.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25322] contextlib.suppress not tested for nested usage

2015-10-06 Thread Raymond Hettinger

Raymond Hettinger added the comment:

That patch looks correct.

--
nosy: +rhettinger

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25322] contextlib.suppress not tested for nested usage

2015-10-06 Thread R. David Murray

R. David Murray added the comment:

Looks good to me.  I hope I never see anything like that in real code, though :)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25322] contextlib.suppress not tested for nested usage

2015-10-06 Thread Frazer McLean

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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25322] contextlib.suppress not tested for nested usage

2015-10-06 Thread Martin Panter

Martin Panter added the comment:

My suggested fix would look like:

with ignore_exceptions:
with ignore_exceptions:  # Check nested usage 
len(5)
ignored = True
1/0
self.assertTrue(ignored)

--
nosy: +martin.panter

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25322] contextlib.suppress not tested for nested usage

2015-10-06 Thread R. David Murray

R. David Murray added the comment:

Oh, I didn't read your message carefully enough. But that makes this bug report 
even more ironic.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25322] contextlib.suppress not tested for nested usage

2015-10-06 Thread R. David Murray

R. David Murray added the comment:

Hah.  I predicted this thing was going to attract bug reports :)

The behavior you observe is how context managers in general and this one in 
particular work.  I'll let Nick explain it, since he wrote it.  Maybe there is 
an doc improvement that would help.

--
nosy: +r.david.murray

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25322] contextlib.suppress not tested for nested usage

2015-10-06 Thread Frazer McLean

Frazer McLean added the comment:

I may not have been clear—I understand how context managers work with 
exceptions.

I'm just pointing out that the nested context manager isn't called, so those 
final two lines aren't testing anything, right?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com