Add comment about try-catch strategy
import socket
+# Figuring out what errors could come out of a socket. There are three
+# different situations. Python 3 post-PEP3151 will define and use
+# BlockingIOError and InterruptedError from sockets. For Python pre-PEP3151
+# both OSError and socket.error can be raised except on Windows where
+# WindowsError can also be raised. We want to catch all of these possible
+# exceptions so we catch WindowsError if it's defined.
try:
_CONNECT_ERROR = (BlockingIOError, InterruptedError)
except NameError:
try:
- _CONNECT_ERROR = (WinError, OSError, socket.error) # noqa: F821
+ _CONNECT_ERROR = (WindowsError, OSError, socket.error) # noqa: F821
except NameError:
_CONNECT_ERROR = (OSError, socket.error)
