-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
bpo-38971: open file in codecs.open() closes if exception raised #17666
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpo-38971: open file in codecs.open() closes if exception raised #17666
Conversation
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA). Recognized GitHub usernameWe couldn't find a bugs.python.org (b.p.o) account corresponding to the following GitHub usernames: This might be simply due to a missing "GitHub Name" entry in one's b.p.o account settings. This is necessary for legal reasons before we can look at this contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. You can check yourself to see if the CLA has been received. Thanks again for the contribution, we look forward to reviewing it! |
Open issue in the BPO indicated a desire to make the implementation of codecs.open() at parity with io.open(), which implements a try/except to assure file stream gets closed before an exception is raised.
96e88dc
to
f6b7759
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix LGTM, but I have some comments about the test.
- Move spec out of seperate class and into CodecsModuleTest - Pass invalid encoding to force exception rather than mock - Specify that a LookupError is raised specifically
@serhiy-storchaka addressed the above comments, should be ready for re-review. thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. Yet a nitpick to tests.
Prefer positional args to keywords in spec Co-Authored-By: Serhiy Storchaka <[email protected]>
@serhiy-storchaka would it be possible to get a re-review of this PR? Thanks in advance! |
Thanks @caporta for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.7. |
Thanks @caporta for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8. |
GH-18733 is a backport of this pull request to the 3.7 branch. |
…thonGH-17666) Open issue in the BPO indicated a desire to make the implementation of codecs.open() at parity with io.open(), which implements a try/except to assure file stream gets closed before an exception is raised. (cherry picked from commit 2565ede) Co-authored-by: Chris A <[email protected]>
…thonGH-17666) Open issue in the BPO indicated a desire to make the implementation of codecs.open() at parity with io.open(), which implements a try/except to assure file stream gets closed before an exception is raised. (cherry picked from commit 2565ede) Co-authored-by: Chris A <[email protected]>
GH-18734 is a backport of this pull request to the 3.8 branch. |
…-17666) Open issue in the BPO indicated a desire to make the implementation of codecs.open() at parity with io.open(), which implements a try/except to assure file stream gets closed before an exception is raised. (cherry picked from commit 2565ede) Co-authored-by: Chris A <[email protected]>
…-17666) Open issue in the BPO indicated a desire to make the implementation of codecs.open() at parity with io.open(), which implements a try/except to assure file stream gets closed before an exception is raised. (cherry picked from commit 2565ede) Co-authored-by: Chris A <[email protected]>
https://bugs.python.org/issue38971
Open issue in the BPO indicated a desire to make the implementation of
codecs.open() at parity with io.open(), which implements a try/except to
assure file stream gets closed before an exception is raised.
https://bugs.python.org/issue38971