Skip to content

Commit ecabbf4

Browse files
Add files via upload
1 parent 634fefd commit ecabbf4

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

pycatfile.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,17 @@ def _wrap(stream):
192192
FileNotFoundError = IOError
193193

194194
try:
195-
UnsupportedOperation = io.UnsupportedOperation # Py3
196-
except AttributeError:
197-
class UnsupportedOperation(IOError): # Py2 fallback
198-
pass
195+
# Works on Py3 and Py2.7
196+
from io import UnsupportedOperation
197+
except Exception:
198+
# Mimic CPython: subclass both OSError/IOError and ValueError
199+
try:
200+
class UnsupportedOperation(IOError, ValueError):
201+
pass
202+
except Exception:
203+
# Ultra-old fallback if multiple inheritance caused issues on exotic runtimes
204+
class UnsupportedOperation(IOError):
205+
pass
199206

200207
# RAR file support
201208
rarfile_support = False

0 commit comments

Comments
 (0)