While looking at the system library implementation, socket.pyI came across this code
try:
import errno
except ImportError:
errno = None
EBADF = getattr(errno, 'EBADF', 9)
EINTR = getattr(errno, 'EINTR', 4)
Is this code just a relic of a bygone age or are there platforms / implementations for which there is no module errno?
To be more explicit, is it safe import errnowithout an exception handler?
I am interested in the answers for both python 2.x and 3.x.
Edit
To clarify the question: I need to check the error codes encoded in the IOErrorexceptions created inside the module socket. The above code, which is in the cpython code database , made me suspicious of known situations in which it socketis available, but import errnofail. Maybe a secondary question, but I would like to avoid unnecessary code.
source
share