Check to see if SO_REUSEPORT is usable and not just defined. by sethmlarson · Pull Request #418 · python/asyncio (original) (raw)
I am sorry, but to me this fix actually causes more problems than it fixes.
Yes, the old error message is rather cryptic and the new exception message is way better, but changing the exception type seems wrong to me. Yes, ValueError might fit better, but changing the type will cause a lot of problems.
- Since an exception is raised as before, code that does not catch anything here will still fail.
- Old code that caught the old
OSErroris now broken, since it does not catchValueError. - New code that catches only
ValueErrorwill fail on older versions of Python, since it does not catchOSError - From what I can see, the documentation mentions neither
OSErrornorValueError, so if a programmer wants to make sure they have proper exception handling for that function, they must check the source, which, depending on their Python version, will say eitherOSErrororValueError, which will break if used on a different version of Python.
My recommendation would be to catch the old OSError and then raise a new OSError with the improved error message.