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.dir_static #55979

Open
voidspace opened this issue Apr 5, 2011 · 6 comments
Open

inspect.dir_static #55979

voidspace opened this issue Apr 5, 2011 · 6 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@voidspace
Copy link
Contributor

BPO 11770
Nosy @merwok, @voidspace, @Trundle, @durban, @PCManticore
Files
  • issue11770.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 = None
    created_at = <Date 2011-04-05.11:08:55.202>
    labels = ['type-feature', 'library']
    title = 'inspect.dir_static'
    updated_at = <Date 2014-01-29.06:44:33.488>
    user = 'https://github.com/voidspace'

    bugs.python.org fields:

    activity = <Date 2014-01-29.06:44:33.488>
    actor = 'Claudiu.Popa'
    assignee = 'michael.foord'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2011-04-05.11:08:55.202>
    creator = 'michael.foord'
    dependencies = []
    files = ['21591']
    hgrepos = []
    issue_num = 11770
    keywords = ['patch']
    message_count = 6.0
    messages = ['133017', '133320', '133322', '133372', '133382', '133434']
    nosy_count = 5.0
    nosy_names = ['eric.araujo', 'michael.foord', 'Trundle', 'daniel.urban', 'Claudiu.Popa']
    pr_nums = []
    priority = 'low'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue11770'
    versions = ['Python 3.5']

    @voidspace
    Copy link
    Contributor Author

    A version of dir that returns all the members that can be seen by getattr_static.

    @voidspace voidspace added the type-bug An unexpected behavior, bug, or error label Apr 5, 2011
    @voidspace voidspace self-assigned this Apr 5, 2011
    @voidspace voidspace added the stdlib Python modules in the Lib dir label Apr 5, 2011
    @merwok
    Copy link
    Member

    merwok commented Apr 8, 2011

    Would it respect __dir__?

    @voidspace
    Copy link
    Contributor Author

    No. It would return all members accessible to getattr_static (which is completely unrelated to what __dir__ may or may not return). Also calling __dir__ would mean code execution, and the point of these functions is to avoid this where possible.

    @Trundle
    Copy link
    Mannequin

    Trundle mannequin commented Apr 9, 2011

    A first patch, misses any documentation changes. While working on it, I realised that modules technically shadow the dict attribute (because modules use tp_dictoffset, hence module have a dict member that points to the instance dict). I updated _shadowed_dict() so that it now disregards member descriptors as shadowing (as they will never trigger any code execution), but theoretically, the members can be any object (not just dicts), so I have to think a bit more about that case (as a custom object still can trigger code execution).

    Also, dir_static() behaves slightly different from dir() (e.g. dir() raises a TypeError if the module's "dict" attribute isn't a dictionary, which is kind of impossible for dir_static as it doesn't even try to acccess __dict__ if it is shadowed), but IMHO such edge-cases are expected to behave differently for a static version and hence we don't care at all about that.

    @voidspace
    Copy link
    Contributor Author

    Thanks for the patch Andreas. On a quick read through it looks good. I'll do a proper review shortly.

    @Trundle
    Copy link
    Mannequin

    Trundle mannequin commented Apr 9, 2011

    See issue bpo-11813 for the module problem.

    @pitrou pitrou added type-feature A feature request or enhancement and removed type-bug An unexpected behavior, bug, or error labels Jul 15, 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-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants