[New-bugs-announce] [issue35992] Metaclasses interfere with __class_getitem__
Caleb Donovick
report at bugs.python.org
Thu Feb 14 01:14:12 EST 2019
New submission from Caleb Donovick <donovick at cs.stanford.edu>:
OS:
Debian testing
python3 -VV:
Python 3.7.2+ (default, Feb 2 2019, 14:31:48)
[gcc 8.2.0]
The following:
```
class Meta(type): pass
class X(metaclass=Meta):
def __class_getitem__(cls, key):
return key
X[10]
```
Results in
```
TypeError: 'Meta' object does not support indexing
```
However, PEP 560 specifically states that __class_getitem__ should be used as fall back for when a metaclass does not implement __getitem__.
----------
assignee: docs at python
components: Documentation, Interpreter Core
messages: 335497
nosy: Donovick, docs at python
priority: normal
severity: normal
status: open
title: Metaclasses interfere with __class_getitem__
type: behavior
versions: Python 3.7
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35992>
_______________________________________
More information about the New-bugs-announce
mailing list