File tree 3 files changed +15
-6
lines changed
3 files changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ Fixed regressions
30
30
31
31
Bug fixes
32
32
~~~~~~~~~
33
- -
33
+ - Most I/O methods do no longer suppress `` OSError `` and `` ValueError `` when closing file handles ( :issue: ` 47136 `)
34
34
-
35
35
36
36
.. ---------------------------------------------------------------------------
Original file line number Diff line number Diff line change @@ -112,11 +112,8 @@ def close(self) -> None:
112
112
self .handle .flush ()
113
113
self .handle .detach ()
114
114
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 ()
120
117
self .created_handles = []
121
118
self .is_wrapped = False
122
119
Original file line number Diff line number Diff line change @@ -600,3 +600,15 @@ def test_fail_mmap():
600
600
with pytest .raises (UnsupportedOperation , match = "fileno" ):
601
601
with BytesIO () as buffer :
602
602
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