Merge {IO,Environment,Windows}Error into OSError for Python 3.3+ (#1852)

Starting with Python 3.3, IOError, EnvironmentError and WindowsError are
aliases for OSError, which has all the attributes.

Reference:
* https://docs.python.org/3/library/exceptions.html#OSError
* https://www.python.org/dev/peps/pep-3151/

* OSError: Drop Python <3.3 compatibility
* Use Any instead of Union for filename/filename2 type, per GvR comment
See: https://github.com/python/mypy/pull/4541
This commit is contained in:
Marti Raudsepp
2018-02-14 18:33:56 +02:00
committed by Łukasz Langa
parent 8d46ada49d
commit d288f443b9

View File

@@ -936,11 +936,18 @@ class SystemExit(BaseException):
code = 0
class Exception(BaseException): ...
class ArithmeticError(Exception): ...
class EnvironmentError(Exception):
class OSError(Exception):
errno = 0
strerror = ... # type: str
# TODO can this be bytes?
filename = ... # type: str
# filename, filename2 are actually Union[str, bytes, None]
filename = ... # type: Any
if sys.version_info >= (3, 4):
filename2 = ... # type: Any
if sys.platform == 'win32':
winerror = 0
IOError = OSError
EnvironmentError = OSError
WindowsError = OSError
class LookupError(Exception): ...
class RuntimeError(Exception): ...
class ValueError(Exception): ...
@@ -949,7 +956,6 @@ class AttributeError(Exception): ...
class BufferError(Exception): ...
class EOFError(Exception): ...
class FloatingPointError(ArithmeticError): ...
class IOError(EnvironmentError): ...
class ImportError(Exception):
if sys.version_info >= (3, 3):
name = ... # type: str
@@ -961,7 +967,6 @@ class KeyError(LookupError): ...
class MemoryError(Exception): ...
class NameError(Exception): ...
class NotImplementedError(RuntimeError): ...
class OSError(EnvironmentError): ...
class BlockingIOError(OSError):
characters_written = 0
class ChildProcessError(OSError): ...
@@ -978,8 +983,6 @@ class NotADirectoryError(OSError): ...
class PermissionError(OSError): ...
class ProcessLookupError(OSError): ...
class TimeoutError(OSError): ...
class WindowsError(OSError):
winerror = ... # type: int
class OverflowError(ArithmeticError): ...
class ReferenceError(Exception): ...
class StopIteration(Exception):