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

Improve errors related to frozen modules. #89542

Open
ericsnowcurrently opened this issue Oct 5, 2021 · 5 comments
Open

Improve errors related to frozen modules. #89542

ericsnowcurrently opened this issue Oct 5, 2021 · 5 comments
Labels
3.11 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@ericsnowcurrently
Copy link
Member

BPO 45379
Nosy @warsaw, @brettcannon, @ambv, @ericsnowcurrently, @FFY00
PRs
  • bpo-45379: raise import error on FROZEN_BAD_NAME #29180
  • bpo-45379: clarify FROZEN_EXCLUDED and FROZEN_INVALID documentation #29189
  • bpo-45379: add custom error string for FROZEN_DISABLED #29190
  • 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 2021-10-05.15:52:00.008>
    labels = ['interpreter-core', 'type-bug', '3.11']
    title = 'Improve errors related to frozen modules.'
    updated_at = <Date 2021-10-29.20:55:22.610>
    user = 'https://github.com/ericsnowcurrently'

    bugs.python.org fields:

    activity = <Date 2021-10-29.20:55:22.610>
    actor = 'lukasz.langa'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Interpreter Core']
    creation = <Date 2021-10-05.15:52:00.008>
    creator = 'eric.snow'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 45379
    keywords = ['patch']
    message_count = 5.0
    messages = ['403246', '404845', '404867', '405260', '405345']
    nosy_count = 5.0
    nosy_names = ['barry', 'brett.cannon', 'lukasz.langa', 'eric.snow', 'FFY00']
    pr_nums = ['29180', '29189', '29190']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue45379'
    versions = ['Python 3.11']

    @ericsnowcurrently
    Copy link
    Member Author

    In Python/import.c there are various situations in which an error state related to frozen modules might result and even lead to an exception. In #72819 we consolidated these cases into a new "frozen_status" enum and added "set_frozen_error()" to set a consistent exception based on a status.

    There are several deficiencies to address at this point:

    • the conditions for the statuses are unclear [1][2]
    • the error messages could be more helpful [3]
    • maybe use a different error message for FROZEN_BAD_NAME (and perhaps FROZEN_DISABLED), rather than combining with FROZEN_NOT_FOUND

    [1] #28633 (comment)
    [2] #28633 (comment)
    [3] #28633 (comment)

    @ericsnowcurrently ericsnowcurrently added 3.11 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels Oct 5, 2021
    @FFY00
    Copy link
    Member

    FFY00 commented Oct 22, 2021

    I was looking at the code and it seems PyImport_ImportFrozenModuleObject does not set an error on FROZEN_BAD_NAME, it just returns 0, is this intended? If I pass a bogus object, it will just return 0.
    This does not seem right.

    Currently, FROZEN_BAD_NAME is never passed to set_frozen_error.

    @FFY00
    Copy link
    Member

    FFY00 commented Oct 23, 2021

    FROZEN_EXCLUDED is set when frozen modules have no code associated with them, and the _freeze_module tool doesn't seem to be able to produce such output.

    We could remove it and replace it with an assert, but that does not give us much benefit, so we should probably leave it be and just document it a little bit better.

    @ambv
    Copy link
    Contributor

    ambv commented Oct 28, 2021

    New changeset 233841a by Filipe Laíns in branch 'main':
    bpo-45379: add custom error string for FROZEN_DISABLED (GH-29190)
    233841a

    @ambv
    Copy link
    Contributor

    ambv commented Oct 29, 2021

    New changeset c2d0ba7 by Filipe Laíns in branch 'main':
    bpo-45379: clarify FROZEN_EXCLUDED and FROZEN_INVALID documentation (GH-29189)
    c2d0ba7

    @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.11 only security fixes 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

    3 participants