Skip to content

Commit 1cf9ac6

Browse files
committed
Ignore OSException along with IOException
1 parent 64d0d4a commit 1cf9ac6

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Src/IronPython.Modules/_warnings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ internal static void showwarning(CodeContext context, object message, PythonType
260260
((TextWriter)file).Write(text);
261261
} // unrecognized file type - warning is lost
262262
}
263-
} catch (IOException) {
263+
} catch (Exception ex) when (ex is IOException or OSException) {
264264
// invalid file - warning is lost
265265
}
266266
}

Src/IronPython/Modules/_fileio.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,10 @@ public override void close(CodeContext/*!*/ context) {
305305

306306
try {
307307
flush(context);
308-
} catch (IOException) {
309-
// flushing can fail, esp. if the other half of a pipe is closed
310-
// ignore it because we're closing anyway
311-
}
308+
} catch (IOException) { /* ignore */ } catch (OSException) { /* ignore */ }
309+
// flushing can fail, esp. if the other half of a pipe is closed
310+
// ignore it because we're closing anyway
311+
312312
_closed = true;
313313

314314
if (_closefd) {

0 commit comments

Comments
 (0)