python / python/cpython

Interrupting class creation in __init_subclass__ may lead to incorrect isinstance() and issubclass() results

Open
#82,266 9 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

interpreter-core type-bug
Dominant language
Python
Stars
77.2k
Forks
36k
PR merge metrics
PR metrics pending

Description

BPO 38085
Nosy @rhettinger, @cfbolz, @ambv, @hongweipeng
PRs
  • python/cpython#30112
  • Files
  • x.py
  • 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 = None
    created_at = <Date 2019-09-10.09:09:41.066>
    labels = ['interpreter-core', '3.8', 'type-bug', '3.7', '3.9']
    title = 'Interrupting class creation in __init_subclass__ may lead to incorrect isinstance() and issubclass() results'
    updated_at = <Date 2021-12-23.20:42:44.132>
    user = 'https://bugs.python.org/xitop'
    

    bugs.python.org fields:

    activity = <Date 2021-12-23.20:42:44.132>
    actor = 'Carl.Friedrich.Bolz'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Interpreter Core']
    creation = <Date 2019-09-10.09:09:41.066>
    creator = 'xitop'
    dependencies = []
    files = ['50515']
    hgrepos = []
    issue_num = 38085
    keywords = ['patch']
    message_count = 9.0
    messages = ['351599', '355037', '358966', '381210', '383796', '401784', '401998', '409106', '409107']
    nosy_count = 5.0
    nosy_names = ['rhettinger', 'Carl.Friedrich.Bolz', 'lukasz.langa', 'hongweipeng', 'xitop']
    pr_nums = ['30112']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue38085'
    versions = ['Python 3.6', 'Python 3.7', 'Python 3.8', 'Python 3.9']
    

    Contributor guide

    Open the contributing guide

    First steps

    1. Read the whole issue, then the project's contributing guide.
    2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
    3. Fork the repository and make your change on a branch.
    4. Open a pull request that references the issue number.

    Research direction

    Start with the attached x.py reproduction and review PR 30112, then read the interpreter-core handling around interrupted init_subclass calls. Done means the reported interruption no longer produces incorrect isinstance() or issubclass() results, with the behavior covered by a regression test.

    Written by the indexing model from the issue text.

    Assessment

    Tech stack
    python
    Domain
    compilers
    Issue type
    Bug
    Difficulty
    4/5
    Estimated time
    3-5 days
    Activity status
    Stale
    Clarity
    Needs clarification
    Newbie friendliness
    20/100

    Get new issues in your inbox

    A short digest of beginner-friendly GitHub issues.