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.

Title: Metaclasses interfere with __class_getitem__
Type: behavior Stage: resolved
Components: Documentation, Interpreter Core Versions: Python 3.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, donovick, gvanrossum, levkivskyi, miss-islington
Priority: normal Keywords: patch

Created on 2019-02-14 06:14 by donovick, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 11857 merged levkivskyi, 2019-02-14 11:56
PR 11910 merged miss-islington, 2019-02-17 23:14
Messages (4)
msg335497 - (view) Author: Caleb Donovick (donovick) * Date: 2019-02-14 06:14
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

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__.
msg335521 - (view) Author: Ivan Levkivskyi (levkivskyi) * (Python committer) Date: 2019-02-14 11:57
Yes, I think this is a bug. Created a PR with a possible simple fix.
msg335790 - (view) Author: Ivan Levkivskyi (levkivskyi) * (Python committer) Date: 2019-02-17 23:13
New changeset ac28147e78c45a6217d348ce90ca5281d91f676f by Ivan Levkivskyi in branch 'master':
bpo-35992: Use PySequence_GetItem only if sq_item is not NULL (GH-11857)
msg335791 - (view) Author: miss-islington (miss-islington) Date: 2019-02-17 23:33
New changeset a7f929db605326da452fbdeebfe341afa9316d25 by Miss Islington (bot) in branch '3.7':
bpo-35992: Use PySequence_GetItem only if sq_item is not NULL (GH-11857)
Date User Action Args
2022-04-11 14:59:11adminsetgithub: 80173
2019-02-17 23:35:10levkivskyisetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2019-02-17 23:33:09miss-islingtonsetnosy: + miss-islington
messages: + msg335791
2019-02-17 23:14:07miss-islingtonsetpull_requests: + pull_request11936
2019-02-17 23:13:55levkivskyisetmessages: + msg335790
2019-02-14 11:57:56levkivskyisetnosy: + gvanrossum
messages: + msg335521
2019-02-14 11:56:42levkivskyisetkeywords: + patch
stage: patch review
pull_requests: + pull_request11889
2019-02-14 06:23:18xtreaksetnosy: + levkivskyi
2019-02-14 06:14:12donovickcreate