This PR avoids the hard-coded error numbers from the PR #14. Instead the available error numbers of the form UV_E* (hence with a single underscore _) are used in modules like stream.pyx and udp.pyx in winloop/handles/. The files uv.pxd and errors.pyx are modified accordingly, also taking advantage of the translation in Python's OSError(), which given an error number and error message automatically returns an instance from a subclass of OSError, like this:
>>> import errno
>>> OSError(errno.EAGAIN, '')
BlockingIOError(11, '')
>>> OSError(11, '')
BlockingIOError(11, '')
>>> OSError(errno.EAGAIN) # conversion is not done if error message is left out
OSError(11)
Maybe the same approach also works for all other errors (incl. the socket errors). I don't really see why not?
This also helps to keep the source code for Winloop as close as possible to the uvloop source code.
This PR avoids the hard-coded error numbers from the PR #14. Instead the available error numbers of the form
UV_E*
(hence with a single underscore_
) are used in modules likestream.pyx
andudp.pyx
inwinloop/handles/
. The filesuv.pxd
anderrors.pyx
are modified accordingly, also taking advantage of the translation in Python's OSError(), which given an error number and error message automatically returns an instance from a subclass ofOSError
, like this:Maybe the same approach also works for all other errors (incl. the socket errors). I don't really see why not? This also helps to keep the source code for Winloop as close as possible to the uvloop source code.