Skip to content

inspect.dir_static #55979

Description

@voidspace
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']

    Activity

    1. voidspace commented on Apr 5, 2011

      @voidspace
      ContributorAuthor

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

    2. self-assigned this
      on Apr 5, 2011
    3. added
      stdlibStandard Library Python modules in the Lib/ directory
      on Apr 5, 2011
    4. merwok commented on Apr 8, 2011

      @merwok
      Member

      Would it respect __dir__?

    5. voidspace commented on Apr 8, 2011

      @voidspace
      ContributorAuthor

      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.

    6. Trundle commented on Apr 9, 2011

      Trundlemannequin
      Mannequin

      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.

    7. voidspace commented on Apr 9, 2011

      @voidspace
      ContributorAuthor

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

    8. Trundle commented on Apr 9, 2011

      Trundlemannequin
      Mannequin

      See issue bpo-11813 for the module problem.

    9. added
      type-featureA feature request or enhancement
      and removed
      type-bugAn unexpected behavior, bug, or error
      on Jul 15, 2011
    10. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions