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

Commitc438649

Browse files
[3.13]gh-136523: Fix wave.Wave_write emitting an unraisable when open raises (GH-136529) (GH-136607)
(cherry picked from commit171de05)Co-authored-by: Sachin Shah <39803835+inventshah@users.noreply.github.com>
1 parentbec9bdf commitc438649

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
@@ -222,6 +223,14 @@ def test_read_wrong_sample_width(self):
222223
withself.assertRaisesRegex(wave.Error,'bad sample width'):
223224
wave.open(io.BytesIO(b))
224225

226+
deftest_open_in_write_raises(self):
227+
# gh-136523: Wave_write.__del__ should not throw
228+
withsupport.catch_unraisable_exception()ascm:
229+
withself.assertRaises(OSError):
230+
wave.open(os.curdir,"wb")
231+
support.gc_collect()
232+
self.assertIsNone(cm.unraisable)
233+
225234

226235
if__name__=='__main__':
227236
unittest.main()

‎Lib/wave.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,8 @@ class Wave_write:
441441
_datawritten -- the size of the audio samples actually written
442442
"""
443443

444+
_file=None
445+
444446
def__init__(self,f):
445447
self._i_opened_the_file=None
446448
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