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

inspect.getattr_static doesn't get module attributes #56022

Closed
Trundle mannequin opened this issue Apr 9, 2011 · 3 comments
Closed

inspect.getattr_static doesn't get module attributes #56022

Trundle mannequin opened this issue Apr 9, 2011 · 3 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@Trundle
Copy link
Mannequin

Trundle mannequin commented Apr 9, 2011

BPO 11813
Nosy @merwok, @voidspace, @Trundle
Files
  • getattr_static_modules.patch
  • 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/voidspace'
    closed_at = <Date 2011-12-18.22:07:17.443>
    created_at = <Date 2011-04-09.22:44:16.268>
    labels = ['type-bug', 'library']
    title = "inspect.getattr_static doesn't get module attributes"
    updated_at = <Date 2011-12-18.22:07:17.442>
    user = 'https://github.com/Trundle'

    bugs.python.org fields:

    activity = <Date 2011-12-18.22:07:17.442>
    actor = 'python-dev'
    assignee = 'michael.foord'
    closed = True
    closed_date = <Date 2011-12-18.22:07:17.443>
    closer = 'python-dev'
    components = ['Library (Lib)']
    creation = <Date 2011-04-09.22:44:16.268>
    creator = 'Trundle'
    dependencies = []
    files = ['21596']
    hgrepos = []
    issue_num = 11813
    keywords = ['patch']
    message_count = 3.0
    messages = ['133432', '149803', '149804']
    nosy_count = 4.0
    nosy_names = ['eric.araujo', 'michael.foord', 'Trundle', 'python-dev']
    pr_nums = []
    priority = 'high'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue11813'
    versions = ['Python 3.2', 'Python 3.3']

    @Trundle
    Copy link
    Mannequin Author

    Trundle mannequin commented Apr 9, 2011

    My patch for issue bpo-11133 introduced a regression: it is no longer possible to get attributes of modules. That is because modules use "tp_dictoffset" (at C level). The instance __dict__ is exposed to Python code using a types.MemberDescriptorType. My patch for issue bpo-11133 currently assumes that accessing the instance __dict__ can trigger code execution, but that is impossible: The access itself can't trigger code execution (it just returns a PyObject in the C struct). Theoretically, it could return any Python object, but that doesn't matter, as the code that uses the object only calls dict methods directly, hence a TypeError is the worst thing that can happen (although it shouldn't ever happen in practise).

    Attached is a patch that adds a test and fixes the issue.

    @Trundle Trundle mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Apr 9, 2011
    @voidspace
    Copy link
    Contributor

    I'd like to commit this patch. What's your real name Trundle, for the NEWS entry?

    @voidspace voidspace self-assigned this Dec 18, 2011
    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Dec 18, 2011

    New changeset 56731ccf2e86 by Michael Foord in branch '3.2':
    Fix inspect.getattr_static to work on modules (again).
    http://hg.python.org/cpython/rev/56731ccf2e86

    @python-dev python-dev mannequin closed this as completed Dec 18, 2011
    @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

    1 participant