Message151320
| Author |
Jim.Jewett |
| Recipients |
Jim.Jewett, ezio.melotti |
| Date |
2012年01月16日.05:05:24 |
| SpamBayes Score |
3.3128744e-10 |
| Marked as misclassified |
No |
| Message-id |
<1326690325.64.0.50515484047.issue13793@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
The documentation for hasattr, getattr, and delattr state that they are equivalent to object.attribute access; this isn't quite true, because object.attribute uses a NFKC-normalized version of the string as only the secondary location, while hasattr, getattr, and delattr (assuming an object rather than an Identifier or string) don't seem to do the normalization at all.
I think the simplest fix would be to normalize and retry when hasattr, getattr, and delattr fail with a string, but I'm not sure that normalization shouldn't be the only string tried.
>>> o.o
Traceback (most recent call last):
File "<pyshell#820>", line 1, in <module>
o.o
AttributeError: 'Object' object has no attribute 'o'
>>> o.o
Traceback (most recent call last):
File "<pyshell#821>", line 1, in <module>
o.o
AttributeError: 'Object' object has no attribute 'o'
>>> o.o=[]
>>> hasattr(o, "o")
False
>>> getattr(o, "o")
Traceback (most recent call last):
File "<pyshell#824>", line 1, in <module>
getattr(o, "o")
AttributeError: 'Object' object has no attribute 'o'
>>> delattr(o, "o")
Traceback (most recent call last):
File "<pyshell#825>", line 1, in <module>
delattr(o, "o")
AttributeError: o
>>> o.o
[]
>>> o.o is o.o
True
>>> o.o
[]
>>> del o.o
>>> o.o
Traceback (most recent call last):
File "<pyshell#830>", line 1, in <module>
o.o
AttributeError: 'Object' object has no attribute 'o'
>>> o.o = 5
>>> hasattr(o, "o")
False
>>> hasattr(o, "o")
True
>>> hasattr(o, "o")
True
>>> o.o
5
>>> delattr(o, "o")
>>> o.o |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2012年01月16日 05:05:25 | Jim.Jewett | set | recipients:
+ Jim.Jewett, ezio.melotti |
| 2012年01月16日 05:05:25 | Jim.Jewett | set | messageid: <1326690325.64.0.50515484047.issue13793@psf.upfronthosting.co.za> |
| 2012年01月16日 05:05:25 | Jim.Jewett | link | issue13793 messages |
| 2012年01月16日 05:05:24 | Jim.Jewett | create |
|