On Aug 24, 2011, at 12:51 PM, Nick Coghlan wrote: >On Wed, Aug 24, 2011 at 9:57 AM, Antoine Pitrou <solip...@pitrou.net> wrote: >> Using IOError.__new__ is the easiest way to ensure that all code >> raising IO errors takes advantage of the errno mapping. Otherwise you >> may get APIs raising the proper subclasses, and other APIs always >> raising base IOError (it doesn't happen often, but some Python >> library code raises an IOError with an explicit errno). > >It's also the natural place to put the errno->exception type mapping >so that existing code will raise the new errors without requiring >modification. We could spell it as a new class method ("from_errno" or >similar), but there isn't any ambiguity in doing it directly in >__new__, so a class method seems pointlessly inconvenient.
As I mentioned, my main concern with this is the surprise factor for people debugging and reading the code. A class method would solve that, but looks uglier and doesn't work with existing code. -Barry _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com