FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-29692: contextlib.contextmanager may incorrectly unchain RuntimeError by soolabettu · Pull Request #949 · python/cpython · GitHub

Repository navigation

bpo-29692: contextlib.contextmanager may incorrectly unchain RuntimeError - #949

Merged
ncoghlan merged 1 commit into
python:masterfrom
soolabettu:bpo-29692
Apr 11, 2017
Merged

ncoghlan merged 1 commit into
python:masterfrom
soolabettu:bpo-29692

Conversation

Copy link
Copy Markdown
Contributor

@ncoghlan @serhiy-storchaka @JelleZijlstra @brettcannon
I had to close PR 891 and open a new PR due to an incorrect rebase on my part.
All review comments made in PR 891 have been implemented and a test case added, please review, thanks.

Copy link
Copy Markdown

@svelankar, thanks for your PR! By analyzing the history of the files in this pull request, we identified @ncoghlan, @berkerpeksag and @Yhg1s to be potential reviewers.

Comment thread Lib/contextlib.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@ncoghlan suggested to drop this else: clause.

Comment thread Lib/test/test_contextlib.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Is this needed in 3.7?

Comment thread Lib/test/test_contextlib.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Add some argument to the raised RuntimeError for checking that the correct RuntimeError is caught.

Comment thread Lib/test/test_contextlib.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Check that this is a RuntimeError raised by test_issue29692, not some other RuntimeError. Check it's __cause__ (it should be ZeroDivisionError, right?).

Comment thread Lib/test/test_contextlib.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

What if raise StopIteration? I think this case should be tested too.

Copy link
Copy Markdown
Member

Please add an entry in Misc/NEWS at the start of the "Library" section. Don't forget "Patch by ."

soolabettu force-pushed the bpo-29692 branch 2 times, most recently from ecf5deb to 9538527 Compare April 2, 2017 11:15

Copy link
Copy Markdown
Contributor Author

Implemented all changes, please review, thanks.

Comment thread Lib/test/test_contextlib.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Since from __future__ import generator_stop no longer used, the trick with exec() no longer needed.

Comment thread Lib/test/test_contextlib.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

assertIsNone()

Comment thread Misc/NEWS Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Add periods after sentence ends.

Copy link
Copy Markdown
Contributor Author

@serhiy-storchaka , thanks for the review.

Copy link
Copy Markdown
Contributor Author

@ncoghlan could you please review the changes? Thanks

ncoghlan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Latest version looks good to me.

ncoghlan merged commit 00c75e9 into python:master Apr 11, 2017

Copy link
Copy Markdown
Contributor

Thanks for the fix, @svelankar!

Mariatta mentioned this pull request Apr 13, 2017
Mariatta pushed a commit to Mariatta/cpython that referenced this pull request Apr 13, 2017
…ntimeError (pythonGH-949)

contextlib._GeneratorContextManager.__exit__ includes a special case to deal with
PEP 479 RuntimeErrors created when `StopIteration` is thrown into the context
manager body.

Previously this check was too permissive, and undid one level of chaining on *all*
RuntimeError instances, not just those that wrapped a StopIteration instance.
(cherry picked from commit 00c75e9)
Mariatta added a commit that referenced this pull request Apr 13, 2017
…ntimeError (GH-949) (#1105)

contextlib._GeneratorContextManager.__exit__ includes a special case to deal with
PEP 479 RuntimeErrors created when `StopIteration` is thrown into the context
manager body.

Previously this check was too permissive, and undid one level of chaining on *all*
RuntimeError instances, not just those that wrapped a StopIteration instance.
(cherry picked from commit 00c75e9)
Mariatta pushed a commit to Mariatta/cpython that referenced this pull request Apr 13, 2017
…ntimeError (pythonGH-949)

contextlib._GeneratorContextManager.__exit__ includes a special case to deal with
PEP 479 RuntimeErrors created when `StopIteration` is thrown into the context
manager body.

Previously this check was too permissive, and undid one level of chaining on *all*
RuntimeError instances, not just those that wrapped a StopIteration instance.
(cherry picked from commit 00c75e9)
Mariatta added a commit that referenced this pull request Apr 13, 2017
…ntimeError (GH-949) (#1107)

contextlib._GeneratorContextManager.__exit__ includes a special case to deal with
PEP 479 RuntimeErrors created when `StopIteration` is thrown into the context
manager body.

Previously this check was too permissive, and undid one level of chaining on *all*
RuntimeError instances, not just those that wrapped a StopIteration instance.
(cherry picked from commit 00c75e9)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants


Back | FazBrowse Home | New Git URL