Navigation Menu

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

PyImport_ExecCodeModuleObject not setting module attributes #65425

Closed
trevor3 mannequin opened this issue Apr 14, 2014 · 7 comments
Closed

PyImport_ExecCodeModuleObject not setting module attributes #65425

trevor3 mannequin opened this issue Apr 14, 2014 · 7 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@trevor3
Copy link
Mannequin

trevor3 mannequin commented Apr 14, 2014

BPO 21226
Nosy @brettcannon, @ncoghlan, @benjaminp, @ericsnowcurrently
Files
  • fix-PyImport_ExecCodeModuleObject.diff
  • fix-PyImport_ExecCodeModuleObject.diff
  • 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/ericsnowcurrently'
    closed_at = <Date 2014-05-13.00:31:35.113>
    created_at = <Date 2014-04-14.21:04:27.103>
    labels = ['type-bug', 'library']
    title = 'PyImport_ExecCodeModuleObject not setting module attributes'
    updated_at = <Date 2014-05-29.18:44:15.513>
    user = 'https://bugs.python.org/trevor3'

    bugs.python.org fields:

    activity = <Date 2014-05-29.18:44:15.513>
    actor = 'python-dev'
    assignee = 'eric.snow'
    closed = True
    closed_date = <Date 2014-05-13.00:31:35.113>
    closer = 'eric.snow'
    components = ['Library (Lib)']
    creation = <Date 2014-04-14.21:04:27.103>
    creator = 'trevor3'
    dependencies = []
    files = ['34971', '34980']
    hgrepos = []
    issue_num = 21226
    keywords = ['patch']
    message_count = 7.0
    messages = ['216217', '216850', '216864', '216886', '218161', '218391', '219356']
    nosy_count = 7.0
    nosy_names = ['brett.cannon', 'ncoghlan', 'benjamin.peterson', 'Arfrever', 'python-dev', 'eric.snow', 'trevor3']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue21226'
    versions = ['Python 3.3', 'Python 3.4', 'Python 3.5']

    @trevor3
    Copy link
    Mannequin Author

    trevor3 mannequin commented Apr 14, 2014

    In Python/import.c, PyImport_ExecCodeModuleObject creates a new module object but doesn't set all of the attributes required for modules, such as __spec__ or __loader__.

    This breaks mod_wsgi from 3.3 and up, which depends on PyImport_ExecCodeModuleEx, which delegates to PyImport_ExecCodeModuleObject for its module creation logic. See https://code.google.com/p/modwsgi/source/browse/mod_wsgi/mod_wsgi.c#6289

    @trevor3 trevor3 mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Apr 14, 2014
    @ericsnowcurrently
    Copy link
    Member

    Here's a (currently segfaulting) patch that demonstrates how I'd like to solve this. Feedback on the approach is welcome. :) When I get a chance I'll debug the segfault.

    @ericsnowcurrently ericsnowcurrently self-assigned this Apr 19, 2014
    @benjaminp
    Copy link
    Contributor

    The last argument to _PyObject_CallMethodIdObjArgs needs to be NULL...

    @ericsnowcurrently
    Copy link
    Member

    Thanks, Benjamin. Here's an updated patch that passes all tests. It should be good to go. And yet again our zipimport implementation was a pain point. :(

    @brettcannon
    Copy link
    Member

    LGTM although you forgot to use a loader instance instead of the class.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented May 13, 2014

    New changeset 7d20e30bd540 by Eric Snow in branch '3.4':
    Issue bpo-21226: Set all attrs in PyImport_ExecCodeModuleObject.
    http://hg.python.org/cpython/rev/7d20e30bd540

    New changeset bc324a49d0fc by Eric Snow in branch 'default':
    Merge from 3.4 (for bpo-21226).
    http://hg.python.org/cpython/rev/bc324a49d0fc

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented May 29, 2014

    New changeset baa7b5555656 by Eric Snow in branch '3.4':
    Issue bpo-21226: fix a ref leak.
    http://hg.python.org/cpython/rev/baa7b5555656

    New changeset 57130574d1e8 by Eric Snow in branch 'default':
    Issue bpo-21226: Merge from 3.4.
    http://hg.python.org/cpython/rev/57130574d1e8

    @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
    stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants