Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit171de05

Browse files
authored
gh-136523: Fix wave.Wave_write emitting an unraisable when open raises (GH-136529)
1 parent42b251b commit171de05

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

‎Lib/test/test_wave.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
fromtestimportaudiotests
33
fromtestimportsupport
44
importio
5+
importos
56
importstruct
67
importsys
78
importwave
@@ -196,6 +197,14 @@ def test_read_wrong_sample_width(self):
196197
withself.assertRaisesRegex(wave.Error,'bad sample width'):
197198
wave.open(io.BytesIO(b))
198199

200+
deftest_open_in_write_raises(self):
201+
# gh-136523: Wave_write.__del__ should not throw
202+
withsupport.catch_unraisable_exception()ascm:
203+
withself.assertRaises(OSError):
204+
wave.open(os.curdir,"wb")
205+
support.gc_collect()
206+
self.assertIsNone(cm.unraisable)
207+
199208

200209
if__name__=='__main__':
201210
unittest.main()

‎Lib/wave.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,8 @@ class Wave_write:
427427
_datawritten -- the size of the audio samples actually written
428428
"""
429429

430+
_file=None
431+
430432
def__init__(self,f):
431433
self._i_opened_the_file=None
432434
ifisinstance(f,str):
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix:class:`wave.Wave_write` emitting an unraisable when open raises.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp