[Python-bugs-list] [Bug #113829] hasattr() doesn't accept Unicode strings

noreply@sourceforge.net noreply@sourceforge.net
Thu, 7 Sep 2000 14:28:38 -0700


Bug #113829, was updated on 2000-Sep-07 14:28
Here is a current snapshot of the bug.

Project: Python
Category: Core
Status: Open
Resolution: None
Bug Group: None
Priority: 5
Summary: hasattr() doesn't accept Unicode strings  

Details: 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

Questions raised by GvR:
There are probably a bunch of things that need to be changed before
this 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.                                                                       

For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=113829&group_id=5470