[Python-ideas] Use `isinstance` check during exception handling
Sjoerd Job Postmus
sjoerdjob at sjec.nl
Thu Nov 5 03:13:49 EST 2015
> On 5 Nov 2015, at 09:05, Serhiy Storchaka <storchaka at gmail.com> wrote:
>
>> On 05.11.15 00:02, sjoerdjob at sjec.nl wrote:
>> Now, PEP3151 took over a year to be resolved, judging by the dates. If
>> we have to go through changes like this more often, one will have to
>> wait quite a while. Also, consider backwards compatibility issues. Code
>> using FileNotFoundError will only run on Python3.3+.
>>
>> Thus I propose to have the exception handling code use the normal
>> `isinstance` machinery, as it is more powerful, and allows one to use
>> virtual base classes to check if the instance of the exception is
>> relevant to catch. An example:
>>
>> import errno
>>
>> # Fake `FileNotFoundError` in Python3.2
>
> Do you propose to add a new feature in 3.2?
Definitely not! PEP3151 was just meant as an example of an improvement of exception granularity taking a long time.
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
More information about the Python-ideas
mailing list