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

assertion failures in case a module has a bad __name__ attribute #75673

Closed
orenmn mannequin opened this issue Sep 16, 2017 · 3 comments
Closed

assertion failures in case a module has a bad __name__ attribute #75673

orenmn mannequin opened this issue Sep 16, 2017 · 3 comments
Labels
3.7 (EOL) end of life interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@orenmn
Copy link
Mannequin

orenmn mannequin commented Sep 16, 2017

BPO 31492
Nosy @ethanfurman, @serhiy-storchaka, @orenmn
PRs
  • bpo-31492: Fix assertion failures in case of a module with a bad __name__ attribute #3620
  • [3.6] bpo-31492: Fix assertion failures in case of a module with a bad __name__ attribute. (GH-3620). #3773
  • 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 2017-09-27.06:46:43.849>
    created_at = <Date 2017-09-16.18:00:45.072>
    labels = ['interpreter-core', '3.7', 'type-crash']
    title = 'assertion failures in case a module has a bad __name__ attribute'
    updated_at = <Date 2017-09-27.06:46:43.849>
    user = 'https://github.com/orenmn'

    bugs.python.org fields:

    activity = <Date 2017-09-27.06:46:43.849>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2017-09-27.06:46:43.849>
    closer = 'serhiy.storchaka'
    components = ['Interpreter Core']
    creation = <Date 2017-09-16.18:00:45.072>
    creator = 'Oren Milman'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 31492
    keywords = ['patch']
    message_count = 3.0
    messages = ['302348', '302514', '303090']
    nosy_count = 3.0
    nosy_names = ['ethan.furman', 'serhiy.storchaka', 'Oren Milman']
    pr_nums = ['3620', '3773']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue31492'
    versions = ['Python 3.6', 'Python 3.7']

    @orenmn
    Copy link
    Mannequin Author

    orenmn mannequin commented Sep 16, 2017

    The following code causes an assertion failure:
    import os
    os.__name__ = None
    os.does_not_exist

    this is because module_getattro() (in Objects/moduleobject.c) assumes that
    __name__ is a string, and passes it to PyErr_Format(), which asserts it is a
    string.

    if we fixed that one (so that the code above would raise an AttributeError),
    the following code would still cause an assertion failure:

    import os
    os.__name__ = None
    from os import does_not_exist

    this is because import_from() (in Python/ceval.c) also assumes that __name__
    is a string, and passes it to PyUnicode_FromFormat(), which asserts it is a
    string.

    BTW, while we are in module_getattro(): isn't the second call to PyErr_Clear()
    redundant? (Ethan, IIUC, you worked on this as part of bpo-8297 some years ago..)

    @orenmn orenmn mannequin added extension-modules C modules in the Modules dir 3.7 (EOL) end of life type-crash A hard crash of the interpreter, possibly with a core dump interpreter-core (Objects, Python, Grammar, and Parser dirs) and removed extension-modules C modules in the Modules dir labels Sep 16, 2017
    @serhiy-storchaka
    Copy link
    Member

    New changeset 6db7033 by Serhiy Storchaka (Oren Milman) in branch 'master':
    bpo-31492: Fix assertion failures in case of a module with a bad __name__ attribute. (bpo-3620)
    6db7033

    @serhiy-storchaka
    Copy link
    Member

    New changeset f0db2df by Serhiy Storchaka in branch '3.6':
    [3.6] bpo-31492: Fix assertion failures in case of a module with a bad __name__ attribute. (GH-3620). (bpo-3773)
    f0db2df

    @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 interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant