While reviewing the system library socket.py implementation I 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 there are platforms/implementations out there for which there is no errno module?
To be more explicit, is it safe to import errno without an exception handler?
I'm interested in answers for both python 2.x and 3.x.
Edit
To clarify the question: I have to test error codes encoded in IOError exceptions raised inside the socket module. The above code, which is in the cpython code base, made me suspicious about known situations in which socket is available, but import errno would fail. Maybe a minor question, but I would like to avoid unnecessary code.