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 complex
Recipients
Date 2007-05-03.22:49:23
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
Unicode strings cannot be used as keys in dictionaries passed as keyword argument to a function. For example:

Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> def fn(**kw):
...     print repr(kw)
...
>>> fn(**{u'x':1})
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: fn() keywords must be strings
>>>

Unicode strings should be converted to str automatically using the site specific default encoding or something similar solution.

This bug caused problems when decoding dictionaries from data formats such as XML or JSON. Usually unicode strings are returned from such modules, such as simplejson. Manual encoding from unicode to str causes performance loss if this cannot be done by Python automatically.
History
Date User Action Args
2007-08-23 16:12:48adminlinkissue1712419 messages
2007-08-23 16:12:48admincreate