[Python-Dev] dict strangeness (original) (raw)
Georg Brandl g.brandl at gmx.net
Sat Mar 18 18:57:12 CET 2006
- Previous message: [Python-Dev] Patch or feature? Tix.Grid working for 2.5
- Next message: [Python-Dev] __dict__ strangeness
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
[moving to python-dev]
Alex Martelli wrote:
Georg Brandl <g.brandl-nospam at gmx.net> wrote:
can someone please tell me that this is correct and why: IMHO, it is not correct: it is a Python bug (and it would be nice to fix it in 2.5).
Fine. Credits go to Michal Kwiatkowski for discovering that in bug #1448042 which I closed out of ignorance ;)
>>> class C(object): ... pass ... >>> c = C() >>> c.a = 1 >>> c.dict {'a': 1} >>> c.dict = {} >>> c.a Traceback (most recent call last): File "", line 1, in ? AttributeError: 'C' object has no attribute 'a' So far so good, I think we agree;-). Yes.
>>> class D(object): ... dict = {} ... >>> d = D() >>> d.a = 1 >>> d.dict {} >>> d.dict = {} >>> d.a 1 Yep, that's the bug, fully reproducible in 2.3 and 2.4. FWIW, mucking around with gc.getreferrers (with a more uniquely identifiable value for d.a;-) shows a dictionary "somewhere" with keys 'a' and 'dict'...
Georg
- Previous message: [Python-Dev] Patch or feature? Tix.Grid working for 2.5
- Next message: [Python-Dev] __dict__ strangeness
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]