osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

"except" and "subclasscheck" changed between CPython2 and 3


On Sat, 03 Mar 2018 04:28:24 +0000, ???? wrote:

> Hello,
> 
> I found a difference of behavior about `except` statement between
> CPython 2.7 and 3.x .
> `except EXC_CLASS:` calls `__subclasscheck__` in 2.7, but does not in
> 3.x .


Python 3 does not accept virtual subclasses for exception handling. They 
have to be concrete subclasses of BaseException.

There is a feature-request to support that (as Python 2.7 does):

https://bugs.python.org/issue12029

but it is stalled.



-- 
Steve