__dict__ strangeness

G

Georg Brandl

Hi,

can someone please tell me that this is correct and why:
.... pass
....Traceback (most recent call last):
.... __dict__ = {}
....1

Thanks,
Georg
 
A

Alan Franzoni

Georg Brandl on comp.lang.python said:

Which Python version, on which system? I can see the properly inserted
attribute in __dict__, both with old style and new style classes.


--
Alan Franzoni <[email protected]>
-
Togli .xyz dalla mia email per contattarmi.
Rremove .xyz from my address in order to contact me.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E
 
G

Georg Brandl

Alan said:
Georg Brandl on comp.lang.python said:


Which Python version, on which system? I can see the properly inserted
attribute in __dict__, both with old style and new style classes.

It's 2.4.2, on Linux. The 2.5 SVN trunk has the same symptom.

Georg
 
A

Alex Martelli

Georg Brandl said:
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).
... pass
...
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: 'C' object has no attribute 'a'

So far so good, I think we agree;-).
... __dict__ = {}
...
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__'...


Alex
 
G

Georg Brandl

[moving to python-dev]

Alex said:
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 ;)
So far so good, I think we agree;-). Yes.


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
 
A

Alex Martelli

Georg Brandl said:
[moving to python-dev]

Alex said:
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 ;)

Yep, I remember Michal posting about the bug here, and I suggested that
he open it as an actual bug on SF;-)... [[I'm supposed to be finishing
up the 2nd edition of the Nutshell, so I can't really do much on Python
myself, these days...]]


Alex
 
Z

Ziga Seilnacht

Georg said:
Hi,

can someone please tell me that this is correct and why:

... pass
...
Traceback (most recent call last):

... __dict__ = {}
...
1

Thanks,
Georg

Here is another example that might help:
.... __dict__ = {'a': 1}
....
e = E()
e.__dict__ {'a': 1}
E.__dict__
E.__dict__['a']
Traceback (most recent call last):
File said:
{'a': 1}

Ziga
 
A

Alan Franzoni

Georg Brandl on comp.lang.python said:
It's 2.4.2, on Linux. The 2.5 SVN trunk has the same symptom.

Yes, I confirm this. I think I had done something strange on my system
(probably misspelled something).

--
Alan Franzoni <[email protected]>
-
Togli .xyz dalla mia email per contattarmi.
Rremove .xyz from my address in order to contact me.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top