Skip to content

Commit

Permalink
Ignore OSException along with IOException
Browse files Browse the repository at this point in the history
  • Loading branch information
BCSharp committed Jan 1, 2025
1 parent 64d0d4a commit 1cf9ac6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Src/IronPython.Modules/_warnings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ internal static void showwarning(CodeContext context, object message, PythonType
((TextWriter)file).Write(text);
} // unrecognized file type - warning is lost
}
} catch (IOException) {
} catch (Exception ex) when (ex is IOException or OSException) {
// invalid file - warning is lost
}
}
Expand Down
8 changes: 4 additions & 4 deletions Src/IronPython/Modules/_fileio.cs
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,10 @@ public override void close(CodeContext/*!*/ context) {

try {
flush(context);
} catch (IOException) {
// flushing can fail, esp. if the other half of a pipe is closed
// ignore it because we're closing anyway
}
} catch (IOException) { /* ignore */ } catch (OSException) { /* ignore */ }
// flushing can fail, esp. if the other half of a pipe is closed
// ignore it because we're closing anyway

_closed = true;

if (_closefd) {
Expand Down

0 comments on commit 1cf9ac6

Please sign in to comment.