This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: abstractmethod does not work when deriving from Exception
Type: behavior Stage: resolved
Components: Versions: Python 3.7, Python 3.6, Python 3.5
process
Status: closed Resolution: duplicate
Dependencies: Superseder: abstract class instantiable when subclassing built-in types
View: 5996
Assigned To: Nosy List: chrysn, xiang.zhang
Priority: normal Keywords:

Created on 2017-02-25 16:46 by chrysn, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
demo.py chrysn, 2017-02-25 16:46 demo that should throw TypeError
Messages (2)
msg288571 - (view) Author: chrysn (chrysn) * Date: 2017-02-25 16:46
The "TypeError: Can't instantiate abstract class C with abstract methods x" exception does not get raised when when the involved ABCMeta class is derived from an Exception.

The attached file shows that a class without an implementation of an abstractmethod can get instanciated; replacing the derivation from Exception with a derivation from another class (say, A) makes the instanciation throw the proper TypeError.
msg288590 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2017-02-26 07:49
Yes. This is the case for builtin types which usually get their own __new__ methods. See #5996.
History
Date User Action Args
2022-04-11 14:58:43adminsetgithub: 73836
2017-02-26 08:06:38serhiy.storchakasetstatus: open -> closed
superseder: abstract class instantiable when subclassing built-in types
dependencies: - abstract class instantiable when subclassing built-in types
resolution: duplicate
stage: resolved
2017-02-26 07:49:41xiang.zhangsetversions: + Python 3.5, Python 3.7
nosy: + xiang.zhang

messages: + msg288590

dependencies: + abstract class instantiable when subclassing built-in types
2017-02-25 16:46:46chrysncreate