Create IoError from Python OSError (IOError in Python 3)
(cls, error: OSError)
| 70 | |
| 71 | @classmethod |
| 72 | def from_io_error(cls, error: OSError) -> "IoError": |
| 73 | """Create IoError from Python OSError (IOError in Python 3)""" |
| 74 | filename = getattr(error, 'filename', None) or '' |
| 75 | strerror = getattr(error, 'strerror', None) or str(error) |
| 76 | return cls(f"{strerror}: {filename}" if filename else strerror) |
| 77 | |
| 78 | |
| 79 | # ============================================================================ |