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

Modules should alway have a dictionary #88652

Closed
markshannon opened this issue Jun 22, 2021 · 2 comments
Closed

Modules should alway have a dictionary #88652

markshannon opened this issue Jun 22, 2021 · 2 comments
Assignees
Labels
type-bug An unexpected behavior, bug, or error

Comments

@markshannon
Copy link
Member

BPO 44486
Nosy @markshannon
PRs
  • bpo-44486: Make sure that modules always have a dictionary. #26847
  • 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 = 'https://github.com/markshannon'
    closed_at = <Date 2021-06-23.16:33:40.350>
    created_at = <Date 2021-06-22.09:53:42.781>
    labels = ['type-bug']
    title = 'Modules should alway have a dictionary'
    updated_at = <Date 2021-06-23.16:33:40.350>
    user = 'https://github.com/markshannon'

    bugs.python.org fields:

    activity = <Date 2021-06-23.16:33:40.350>
    actor = 'Mark.Shannon'
    assignee = 'Mark.Shannon'
    closed = True
    closed_date = <Date 2021-06-23.16:33:40.350>
    closer = 'Mark.Shannon'
    components = []
    creation = <Date 2021-06-22.09:53:42.781>
    creator = 'Mark.Shannon'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 44486
    keywords = ['patch']
    message_count = 2.0
    messages = ['396316', '396391']
    nosy_count = 1.0
    nosy_names = ['Mark.Shannon']
    pr_nums = ['26847']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue44486'
    versions = []

    @markshannon
    Copy link
    Member Author

    It is possible to create a module without a dictionary:
    m = types.ModuleType.__new__(types.ModuleType)

    But that is the only way to create to a module without a dict; all other means of creating a module, both in Python and in the C API, result in a fully formed module.

    Existing code expects that modules will always have a dictionary, e.g.
    https://github.com/python/cpython/blob/3.10/Include/internal/pycore_moduleobject.h#L35

    We should change types.ModuleType.__new__ to properly initialize the module.

    @markshannon markshannon self-assigned this Jun 22, 2021
    @markshannon markshannon added the type-bug An unexpected behavior, bug, or error label Jun 22, 2021
    @markshannon markshannon self-assigned this Jun 22, 2021
    @markshannon markshannon added the type-bug An unexpected behavior, bug, or error label Jun 22, 2021
    @markshannon
    Copy link
    Member Author

    New changeset c3f52b4 by Mark Shannon in branch 'main':
    bpo-44486: Make sure that modules always have a dictionary. (GH-26847)
    c3f52b4

    @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
    type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant