File tree Expand file tree Collapse file tree 3 files changed +15
-6
lines changed
Expand file tree Collapse file tree 3 files changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ Fixed regressions
3030
3131Bug fixes
3232~~~~~~~~~
33- -
33+ - Most I/O methods do no longer suppress `` OSError `` and `` ValueError `` when closing file handles ( :issue: ` 47136 `)
3434-
3535
3636.. ---------------------------------------------------------------------------
Original file line number Diff line number Diff line change @@ -112,11 +112,8 @@ def close(self) -> None:
112112 self .handle .flush ()
113113 self .handle .detach ()
114114 self .created_handles .remove (self .handle )
115- try :
116- for handle in self .created_handles :
117- handle .close ()
118- except (OSError , ValueError ):
119- pass
115+ for handle in self .created_handles :
116+ handle .close ()
120117 self .created_handles = []
121118 self .is_wrapped = False
122119
Original file line number Diff line number Diff line change @@ -600,3 +600,15 @@ def test_fail_mmap():
600600 with pytest .raises (UnsupportedOperation , match = "fileno" ):
601601 with BytesIO () as buffer :
602602 icom .get_handle (buffer , "rb" , memory_map = True )
603+
604+
605+ def test_close_on_error ():
606+ # GH 47136
607+ class TestError :
608+ def close (self ):
609+ raise OSError ("test" )
610+
611+ with pytest .raises (OSError , match = "test" ):
612+ with BytesIO () as buffer :
613+ with icom .get_handle (buffer , "rb" ) as handles :
614+ handles .created_handles .append (TestError ())
You can’t perform that action at this time.
0 commit comments