This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: dir(dictobject) returns empty list when __getattribute__ is overriden in the class
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 2.7
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List:, r.david.murray, rhettinger
Priority: normal Keywords:

Created on 2015-06-04 05:06 by, last changed 2022-04-11 14:58 by admin. This issue is now closed.

File name Uploaded Description Edit, 2015-06-04 05:06
Messages (2)
msg244798 - (view) Author: Alka Yadav ( Date: 2015-06-04 05:06
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.
msg244822 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2015-06-04 14:10
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.
Date User Action Args
2022-04-11 14:58:17adminsetgithub: 68566
2015-06-04 14:10:25r.david.murraysetstatus: open -> closed

type: crash -> behavior

nosy: + r.david.murray
messages: + msg244822
resolution: not a bug
stage: resolved
2015-06-04 05:44:01rhettingersetnosy: + rhettinger
2015-06-04 05:06:36alkayadavit07@gmail.comcreate