[issue36042] Setting __init_subclass__ and __class_getitem__ methods are in runtime doesnt make them class method.

Raymond Hettinger report at bugs.python.org
Tue Feb 19 18:40:31 EST 2019


Raymond Hettinger <raymond.hettinger at gmail.com> added the comment:

> CPython only makes these methods class method when a class created.
> If you set __class_getitem__ method after the creation it 
> doesn't work unless you use classmethod decorator manually.

Give the intended use case for __class_getitem__ and that it was replacement for metaclass code with the same effect, the current behavior doesn't seem unreasonable.  That said, I don't see any downside to allowing the method to attach after class creation.

Assigning to Ivan to make the call on this one.

----------
assignee:  -> levkivskyi
components: +Interpreter Core
nosy: +rhettinger
type: behavior -> enhancement
versions: +Python 3.8

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


More information about the Python-bugs-list mailing list