You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is this a bug in how the TimeoutError is raised? Or can the attributes be None which should be documented?
importsockets=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(0.1)
try:
s.connect(("10.10.10.10", 22))
exceptOSErrorasex:
print(repr(ex))
print(f"errno is {type(ex.errno)} - {ex.errno}")
print(f"strerror is {type(ex.strerror)} - {ex.strerror}")
# But the `FileNotFoundError` has the correct attributes are setimportostry:
os.listdir("non_existing_path")
exceptOSErrorasex:
print(repr(ex))
print(f"errno is {type(ex.errno)} - {ex.errno}")
print(f"strerror is {type(ex.strerror)} - {ex.strerror}")
Bug report
Bug description:
According to the docs
OSError
https://docs.python.org/3/library/exceptions.html#OSError has the attributeserrno
andstrerror
(integer and string respectively) set on this class and sub-classes likeTimeoutError
https://docs.python.org/3/library/exceptions.html#TimeoutErrorAnd the
TimeoutError
is mapped toerrno
https://docs.python.org/3/library/errno.html#errno.ETIMEDOUT which has a default value depending on the OS.Is this a bug in how the
TimeoutError
is raised? Or can the attributes beNone
which should be documented?Ref: python/typeshed#9864
CPython versions tested on:
3.11
Operating systems tested on:
Linux
The text was updated successfully, but these errors were encountered: