> hasattr(), getattr(), and doubtless other built-in functions > don't accept Unicode strings at all: > > >>> import sys > >>> hasattr(sys, u'abc') > Traceback (most recent call last): > File "<stdin>", line 1, in ? > TypeError: hasattr, argument 2: expected string, unicode found > > Is this a bug or a feature? I'd say bug; the Unicode should be > coerced using the default ASCII encoding, and an exception raised if > that isn't possible. Agreed. There are probably a bunch of things that need to be changed before thois works though; getattr() c.s. require a string, then call PyObject_GetAttr() which also checks for a string unless the object supports tp_getattro -- but that's only true for classes and instances. Also, should we convert the string to 8-bit, or should we allow Unicode attribute names? It seems there's no easy fix -- better address this after 2.0 is released. --Guido van Rossum (home page: http://www.pythonlabs.com/~guido/)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4