Skip to content

Commit dad16f2

Browse files
srittauJelleZijlstra
authored andcommitted
Update socket exceptions (#3127)
* error is an alias for OSError in Python 3 * herror and gaierror can be constructed without arguments (tested in Python 2.7 and 3.7) * timeout uses the same arguments as herror and gaierror
1 parent 40215d1 commit dad16f2

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

stdlib/2and3/socket.pyi

+7-5
Original file line numberDiff line numberDiff line change
@@ -481,17 +481,19 @@ else:
481481

482482

483483
# ----- exceptions -----
484-
class error(IOError):
485-
...
484+
if sys.version_info < (3,):
485+
class error(IOError): ...
486+
else:
487+
error = OSError
486488

487489
class herror(error):
488-
def __init__(self, herror: int, string: str) -> None: ...
490+
def __init__(self, herror: int = ..., string: str = ...) -> None: ...
489491

490492
class gaierror(error):
491-
def __init__(self, error: int, string: str) -> None: ...
493+
def __init__(self, error: int = ..., string: str = ...) -> None: ...
492494

493495
class timeout(error):
494-
...
496+
def __init__(self, error: int = ..., string: str = ...) -> None: ...
495497

496498

497499
# Addresses can be either tuples of varying lengths (AF_INET, AF_INET6,

0 commit comments

Comments
 (0)