Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/tblib/pickling_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ def pickle_exception(
}
args = ()
if isinstance(obj, OSError):
attrs.update(errno=obj.errno, strerror=obj.strerror)
# Only set OSError-specific attributes if they are not None
# Setting them to None explicitly breaks the string representation
if obj.errno is not None:
attrs['errno'] = obj.errno
if obj.strerror is not None:
attrs['strerror'] = obj.strerror
if (winerror := getattr(obj, 'winerror', None)) is not None:
attrs['winerror'] = winerror
if obj.filename is not None:
Expand Down