[issue29692] contextlib.contextmanager may incorrectly unchain RuntimeError

2017-04-13 Thread Mariatta Wijaya

Mariatta Wijaya added the comment:

PR has been backported into 3.5 and 3.6. Thanks all :)

--
stage: backport needed -> resolved
status: open -> closed
versions: +Python 3.7

___
Python tracker 

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



[issue29692] contextlib.contextmanager may incorrectly unchain RuntimeError

2017-04-13 Thread Mariatta Wijaya

Mariatta Wijaya added the comment:


New changeset 4d015a40a7b9c3c1b8cfbe81453187d700a43163 by Mariatta in branch 
'3.5':
[3.5] bpo-29692: contextlib.contextmanager may incorrectly unchain RuntimeError 
(GH-949) (#1107)
https://github.com/python/cpython/commit/4d015a40a7b9c3c1b8cfbe81453187d700a43163


--

___
Python tracker 

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



[issue29692] contextlib.contextmanager may incorrectly unchain RuntimeError

2017-04-13 Thread Mariatta Wijaya

Changes by Mariatta Wijaya :


--
pull_requests: +1247

___
Python tracker 

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



[issue29692] contextlib.contextmanager may incorrectly unchain RuntimeError

2017-04-13 Thread Mariatta Wijaya

Mariatta Wijaya added the comment:


New changeset 9b409ff41ceb2d7ea7e8d25a7bbf5eb7d46625f3 by Mariatta in branch 
'3.6':
[3.6] bpo-29692: contextlib.contextmanager may incorrectly unchain RuntimeError 
(GH-949) (#1105)
https://github.com/python/cpython/commit/9b409ff41ceb2d7ea7e8d25a7bbf5eb7d46625f3


--
nosy: +Mariatta

___
Python tracker 

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



[issue29692] contextlib.contextmanager may incorrectly unchain RuntimeError

2017-04-12 Thread Mariatta Wijaya

Changes by Mariatta Wijaya :


--
pull_requests: +1244

___
Python tracker 

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



[issue29692] contextlib.contextmanager may incorrectly unchain RuntimeError

2017-04-11 Thread Nick Coghlan

Nick Coghlan added the comment:


New changeset e8a6bb4f3936123f3eca0b6cea05e2875a2722bc by Nick Coghlan in 
branch 'master':
bpo-29692: Add missing ACKS entry (#1079)
https://github.com/python/cpython/commit/e8a6bb4f3936123f3eca0b6cea05e2875a2722bc


--

___
Python tracker 

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



[issue29692] contextlib.contextmanager may incorrectly unchain RuntimeError

2017-04-11 Thread Nick Coghlan

Changes by Nick Coghlan :


--
pull_requests: +1222

___
Python tracker 

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



[issue29692] contextlib.contextmanager may incorrectly unchain RuntimeError

2017-04-11 Thread Nick Coghlan

Changes by Nick Coghlan :


--
assignee:  -> ncoghlan

___
Python tracker 

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



[issue29692] contextlib.contextmanager may incorrectly unchain RuntimeError

2017-04-11 Thread Nick Coghlan

Nick Coghlan added the comment:

This has been merged for 3.7, but cherry-picks to the other branches are still 
needed.

I also inadvertently missed adding svelankar's name (Siddharth Velankar) to 
Misc/ACKS, so that oversight will need to be tidied up as well.

--
resolution:  -> fixed
stage: test needed -> backport needed
versions:  -Python 3.7

___
Python tracker 

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



[issue29692] contextlib.contextmanager may incorrectly unchain RuntimeError

2017-04-11 Thread Nick Coghlan

Nick Coghlan added the comment:


New changeset 00c75e9a45ff0366c185e9e8a2e23af5a35481b0 by Nick Coghlan 
(svelankar) in branch 'master':
bpo-29692: contextlib.contextmanager may incorrectly unchain RuntimeError 
(GH-949)
https://github.com/python/cpython/commit/00c75e9a45ff0366c185e9e8a2e23af5a35481b0


--

___
Python tracker 

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



[issue29692] contextlib.contextmanager may incorrectly unchain RuntimeError

2017-04-09 Thread svelankar

Changes by svelankar :


--
nosy: +svelankar

___
Python tracker 

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



[issue29692] contextlib.contextmanager may incorrectly unchain RuntimeError

2017-04-05 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Then the exception for the __exit__ method should be documented in PEP 8.

--

___
Python tracker 

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



[issue29692] contextlib.contextmanager may incorrectly unchain RuntimeError

2017-04-05 Thread Raymond Hettinger

Raymond Hettinger added the comment:

PEP 8's rule makes sense elsewhere, but for context managers I think an 
implicit return None is the norm and that making it explicit wouldn't improve 
readability.

--
nosy: +rhettinger

___
Python tracker 

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



[issue29692] contextlib.contextmanager may incorrectly unchain RuntimeError

2017-04-01 Thread svelankar

Changes by svelankar :


--
pull_requests: +1131

___
Python tracker 

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



[issue29692] contextlib.contextmanager may incorrectly unchain RuntimeError

2017-03-29 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

The __exit__() method doesn't conform PEP 8.

PEP 8: """Be consistent in return statements. Either all return statements in a 
function should return an expression, or none of them should. If any return 
statement returns an expression, any return statements where no value is 
returned should explicitly state this as return None , and an explicit return 
statement should be present at the end of the function (if reachable)."""

The __exit__() method has explicit "return False", bare "return", and implicit 
"return" at the end of the method. Together with different styles in different 
"except" clauses this makes it slightly hard to read.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue29692] contextlib.contextmanager may incorrectly unchain RuntimeError

2017-03-29 Thread svelankar

Changes by svelankar :


--
pull_requests: +794

___
Python tracker 

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



[issue29692] contextlib.contextmanager may incorrectly unchain RuntimeError

2017-03-02 Thread Jelle Zijlstra

Changes by Jelle Zijlstra :


--
nosy: +Jelle Zijlstra

___
Python tracker 

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



[issue29692] contextlib.contextmanager may incorrectly unchain RuntimeError

2017-03-02 Thread Nick Coghlan

New submission from Nick Coghlan:

As part of PEP 479, an extra check was added to 
contextlib._GeneratorContextManager to avoid getting confused when a 
StopIteration exception was raised in the body of the with statement, and hence 
thrown into the generator body implementing the context manager.

This extra check should only be used when the passed in exception is 
`StopIteration`, but that guard is currently missing, so it may unchain 
arbitrary RuntimeError exceptions if they set their `__cause__` to the 
originally passed in value.

Compare the current contextmanager behaviour:

```
>>> from contextlib import contextmanager
>>> @contextmanager
... def chain_thrown_exc():
... try:
... yield
... except Exception as exc:
... raise RuntimeError("Chained!") from exc
... 
>>> with chain_thrown_exc():
... 1/0
... 
Traceback (most recent call last):
  File "", line 2, in 
ZeroDivisionError: division by zero
```

To the expected inline behaviour:

```
>>> try:
... 1/0
... except Exception as exc:
... raise RuntimeError("Chained!") from exc
... 
Traceback (most recent call last):
  File "", line 2, in 
ZeroDivisionError: division by zero

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "", line 4, in 
RuntimeError: Chained!

```

--
keywords: 3.5regression
messages: 288793
nosy: ncoghlan
priority: normal
severity: normal
stage: test needed
status: open
title: contextlib.contextmanager may incorrectly unchain RuntimeError
type: behavior
versions: Python 3.5, Python 3.6, Python 3.7

___
Python tracker 

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