homepage

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.

Author Albert.Zeyer
Recipients Albert.Zeyer
Date 2012年04月23日.22:53:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1335221613.52.0.779214050633.issue14658@psf.upfronthosting.co.za>
In-reply-to
Content
```
class Foo1(dict):
 def __getattr__(self, key): return self[key]
 def __setattr__(self, key, value): self[key] = value
class Foo2(dict):
 __getattr__ = dict.__getitem__
 __setattr__ = dict.__setitem__
o1 = Foo1()
o1.x = 42
print(o1, o1.x)
o2 = Foo2()
o2.x = 42
print(o2, o2.x)
```
With CPython 2.5, 2.6 (similarly in 3.2), I get:
({'x': 42}, 42)
({}, 42)
With PyPy 1.5.0, I get the expected output::
({'x': 42}, 42)
({'x': 42}, 42)
I asked this also on SO: http://stackoverflow.com/questions/6305267/python-inconsistence-in-the-way-you-define-the-function-setattr
From the answers, I am not exactly sure wether this is considered as a bug in CPython or not. Anyway, I just wanted to post this here.
History
Date User Action Args
2012年04月23日 22:53:33Albert.Zeyersetrecipients: + Albert.Zeyer
2012年04月23日 22:53:33Albert.Zeyersetmessageid: <1335221613.52.0.779214050633.issue14658@psf.upfronthosting.co.za>
2012年04月23日 22:53:32Albert.Zeyerlinkissue14658 messages
2012年04月23日 22:53:32Albert.Zeyercreate

AltStyle によって変換されたページ (->オリジナル) /