-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
gh-136523: fix Wave_write.__del__ raise after attempt to open protected file #136529
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
base: main
Are you sure you want to change the base?
Conversation
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
@@ -196,6 +197,22 @@ def test_read_wrong_sample_width(self): | |||
with self.assertRaisesRegex(wave.Error, 'bad sample width'): | |||
wave.open(io.BytesIO(b)) | |||
|
|||
@skip_unless_working_chmod | |||
def test_write_to_protected_file(self): | |||
# gh-136523: Wave_write.__del__ should not throw |
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.
I'm not sure if it's better to add issue number here(?) We've got blame
in git for this
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.
I was following the pattern found in other test files where the issue number (136523
) is placed in a comment. If it is better practice to have developers trace through git blame
/ the commit message to find the issue, I'm happy to remove this. (Note the PR and issue number start with the same 5 digits)
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.
I think that linking issue numbers is fine, as we can lose the blame when people do refactoring. (And, it's just easier to look up an issue than go through the blame.)
Fixes #136523, by moving
builtins.open
inside thetry-except
block and always callinginitfp
(which does not raise) forWave_write
.Wave_write.__del__()
after failed attempt to open file for write operation #136523