◐ Shell
clean mode source ↗

Check to see if SO_REUSEPORT is usable and not just defined. by sethmlarson · Pull Request #418 · python/asyncio

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 OSError is now broken, since it does not catch ValueError.
  • New code that catches only ValueError will fail on older versions of Python, since it does not catch OSError
  • From what I can see, the documentation mentions neither OSError nor ValueError, 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 either OSError or ValueError, 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.