Skip to content

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

inventshah
Copy link

@inventshah inventshah commented Jul 11, 2025

Fixes #136523, by moving builtins.open inside the try-except block and always calling initfp (which does not raise) for Wave_write.

@python-cla-bot
Copy link

python-cla-bot bot commented Jul 11, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app
Copy link

bedevere-app bot commented Jul 11, 2025

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 skip news label instead.

@@ -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
Copy link
Contributor

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

Copy link
Author

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)

Copy link
Member

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.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exception raised from Wave_write.__del__() after failed attempt to open file for write operation
3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy