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

dir(dictobject) returns empty list when __getattribute__ is overriden in the class #68566

Closed
alkayadavit07gmailcom mannequin opened this issue Jun 4, 2015 · 2 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@alkayadavit07gmailcom
Copy link
Mannequin

alkayadavit07gmailcom mannequin commented Jun 4, 2015

BPO 24378
Nosy @rhettinger, @bitdancer
Files
  • direrror.py
  • 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 = <Date 2015-06-04.14:10:25.827>
    created_at = <Date 2015-06-04.05:06:36.712>
    labels = ['invalid', 'type-bug', 'library']
    title = 'dir(dictobject) returns empty list when __getattribute__ is overriden in the class'
    updated_at = <Date 2015-06-04.14:10:25.792>
    user = 'https://bugs.python.org/alkayadavit07gmailcom'

    bugs.python.org fields:

    activity = <Date 2015-06-04.14:10:25.792>
    actor = 'r.david.murray'
    assignee = 'none'
    closed = True
    closed_date = <Date 2015-06-04.14:10:25.827>
    closer = 'r.david.murray'
    components = ['Library (Lib)']
    creation = <Date 2015-06-04.05:06:36.712>
    creator = 'alkayadavit07@gmail.com'
    dependencies = []
    files = ['39613']
    hgrepos = []
    issue_num = 24378
    keywords = []
    message_count = 2.0
    messages = ['244798', '244822']
    nosy_count = 3.0
    nosy_names = ['rhettinger', 'r.david.murray', 'alkayadavit07@gmail.com']
    pr_nums = []
    priority = 'normal'
    resolution = 'not a bug'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue24378'
    versions = ['Python 2.7']

    @alkayadavit07gmailcom
    Copy link
    Mannequin Author

    alkayadavit07gmailcom mannequin commented Jun 4, 2015

    When __getattribute__ method is overrriden in a class,then in case of calling
    an attribute not in class object should throw KeyError.

    But when calling dir on classs object gives an empty list as dir(dictobject)
    calls dictobject.__getattribute__(dir) and it throws KeyError instead of AttributeError in dir annd it returns NULL upstream

    So dir source code need to be fixed to catch KeyError appropriately.

    @alkayadavit07gmailcom alkayadavit07gmailcom mannequin added type-crash A hard crash of the interpreter, possibly with a core dump stdlib Python modules in the Lib dir labels Jun 4, 2015
    @bitdancer
    Copy link
    Member

    If you override __getattribute__ it is your responsibility to fulfill its contract, so your method is the one that needs to catch the KeyError and return the expected AttributeError.

    @bitdancer bitdancer added invalid type-bug An unexpected behavior, bug, or error and removed type-crash A hard crash of the interpreter, possibly with a core dump labels Jun 4, 2015
    @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