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.

classification
Title: dir should accept dirproxies for __dict__
Type: enhancement Stage: test needed
Components: Interpreter Core Versions: Python 3.2
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: BreamoreBoy, ronaldoussoren
Priority: low Keywords:

Created on 2005-07-31 13:21 by ronaldoussoren, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg25913 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2005-07-31 13:21
PyObject_Dir checks if the __dict__ of an object is a dict, if not it is 
ignored. It should also accept dictproxies.

My usecase is an object that doesn't have a real dict, but looks up 
attributes in another datastructure. When someone asks for the 
__dict__ of this object I'm dynamicly building a new dictionary. I'd 
like the __dict__ property to be a immutable value because changing 
it won't (and shouldn't) affect the underlying object. 

However, when I return the result of a call to PyDict_NewProxy the 
builtin function dir will no longer use the contents of the __dict__ 
attribute, which is counterproductive because supporting dict is a 
major usecase for supporting a __dict__ attribute in the first place!
msg109748 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010-07-09 15:15
Ronald has this already been implemented, if not could you provide a patch for it, or what?
msg109750 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2010-07-09 15:18
AFAIK this is not yet implemented.

Patched would be appreciated. I will get around to doing it myself some day, but this issue doesn't have high priority for me.
msg173585 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2012-10-23 09:37
This is not relevant for supported python releases: in python 2.6 and later my usecase can be implemented using the magic method __dir__.

I'm therefore closing this issue.
History
Date User Action Args
2022-04-11 14:56:12adminsetgithub: 42233
2012-10-23 09:37:35ronaldoussorensetstatus: open -> closed
resolution: rejected
messages: + msg173585
2010-07-09 15:18:32ronaldoussorensetpriority: normal -> low

messages: + msg109750
2010-07-09 15:15:42BreamoreBoysetnosy: + BreamoreBoy

messages: + msg109748
versions: + Python 3.2, - Python 2.7
2009-02-16 02:26:23ajaksu2setstage: test needed
type: enhancement
versions: + Python 2.7, - Python 2.4
2005-07-31 13:21:05ronaldoussorencreate