Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metaclasses interfere with __class_getitem__ #80173

Closed
cdonovick mannequin opened this issue Feb 14, 2019 · 4 comments
Closed

Metaclasses interfere with __class_getitem__ #80173

cdonovick mannequin opened this issue Feb 14, 2019 · 4 comments
Labels
3.7 (EOL) end of life docs Documentation in the Doc dir interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@cdonovick
Copy link
Mannequin

cdonovick mannequin commented Feb 14, 2019

BPO 35992
Nosy @gvanrossum, @ilevkivskyi, @miss-islington, @cdonovick
PRs
  • bpo-35992: Use PySequence_GetItem only if sq_item is not NULL #11857
  • [3.7] bpo-35992: Use PySequence_GetItem only if sq_item is not NULL (GH-11857) #11910
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2019-02-17.23:35:10.511>
    created_at = <Date 2019-02-14.06:14:12.765>
    labels = ['interpreter-core', 'type-bug', '3.7', 'docs']
    title = 'Metaclasses interfere with __class_getitem__'
    updated_at = <Date 2019-02-17.23:35:10.510>
    user = 'https://github.com/cdonovick'

    bugs.python.org fields:

    activity = <Date 2019-02-17.23:35:10.510>
    actor = 'levkivskyi'
    assignee = 'docs@python'
    closed = True
    closed_date = <Date 2019-02-17.23:35:10.511>
    closer = 'levkivskyi'
    components = ['Documentation', 'Interpreter Core']
    creation = <Date 2019-02-14.06:14:12.765>
    creator = 'donovick'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 35992
    keywords = ['patch']
    message_count = 4.0
    messages = ['335497', '335521', '335790', '335791']
    nosy_count = 5.0
    nosy_names = ['gvanrossum', 'docs@python', 'levkivskyi', 'miss-islington', 'donovick']
    pr_nums = ['11857', '11910']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue35992'
    versions = ['Python 3.7']

    @cdonovick
    Copy link
    Mannequin Author

    cdonovick mannequin commented Feb 14, 2019

    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__.

    @cdonovick cdonovick mannequin added the 3.7 (EOL) end of life label Feb 14, 2019
    @cdonovick cdonovick mannequin assigned docspython Feb 14, 2019
    @cdonovick cdonovick mannequin added docs Documentation in the Doc dir interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels Feb 14, 2019
    @ilevkivskyi
    Copy link
    Member

    Yes, I think this is a bug. Created a PR with a possible simple fix.

    @ilevkivskyi
    Copy link
    Member

    New changeset ac28147 by Ivan Levkivskyi in branch 'master':
    bpo-35992: Use PySequence_GetItem only if sq_item is not NULL (GH-11857)
    ac28147

    @miss-islington
    Copy link
    Contributor

    New changeset a7f929d by Miss Islington (bot) in branch '3.7':
    bpo-35992: Use PySequence_GetItem only if sq_item is not NULL (GH-11857)
    a7f929d

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life docs Documentation in the Doc dir interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants