[issue34284] Nonsensical exception message when calling `__new__` on non-instaniable objects

ppperry report at bugs.python.org
Sat Aug 4 12:25:38 EDT 2018


ppperry <mapreader at olum.org> added the comment:

The problem doesn't just happen with `sys.flags`, though. It happens with all types that can't be created directly by python. Ex: frame objects, generators, cells, etc. The bug is that in types whose c-level tp_new is null, the python-level __new__ is inherited from the superclass (and since object defines a `__new__`, such a function always exists), instead of being defined to always raise an error, like calling the type directly does.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34284>
_______________________________________


More information about the Python-bugs-list mailing list