
April 7, 2011
9:17 a.m.
On Thu, 07 Apr 2011 10:43:25 +0200 "M.-A. Lemburg" <mal@egenix.com> wrote:
It would be even more useful, if there were a way to catch standard IOErrors with those errnos using those same classes, so that the following becomes possible:
try: ... raise IOError(errno.EPERM, "permission denied") except PermissionError: ...
and works as one would expect, that is, catch the EPERM error.
Perhaps the IOError constructor could be made to switch the class of the generated object based on the errno attribute passed to the constructor.
Nice suggestion. I'll try to see if that is possible. Regards Antoine.