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.

Title: Python does not accept unicode keywords
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 2.6
Status: closed Resolution: out of date
Dependencies: Superseder: allow unicode keyword args
View: 4978
Assigned To: Nosy List: ajaksu2, belopolsky, j5
Priority: normal Keywords: 26backport

Created on 2008-04-16 21:40 by j5, last changed 2022-04-11 14:56 by admin. This issue is now closed.

File name Uploaded Description Edit
allow_unicode_keywords.patch j5, 2008-04-16 21:40
issue2646.diff belopolsky, 2008-04-17 05:26 Patch against revision 62359
Messages (4)
msg65567 - (view) Author: John (J5) Palmieri (j5) Date: 2008-04-16 21:40
# given this function

def a(**kwargs):

# this works

# this throws a format error

I am using a web framework (TurboGears w/ genshi templating) which often
pass around dictionaries as keyword arguments in order to have 1 to 1
representation of json data and URL parameters.  This is usually fine
except when using libraries such as simplejson which encodes all of the
keywords as unicode.

Attached is a patch which is most likely just the tip of the iceberg but
hopefully it turns out to be this easy.
msg65568 - (view) Author: John (J5) Palmieri (j5) Date: 2008-04-16 22:15
Someone has convinced me that it is not worth bothering the dev team
since they will have this fixed in P3k the right way. If it is easy then
please fix this, otherwise feel free to close.
msg65572 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2008-04-17 04:43
I would say this is a good idea for 2.6.

Note that C functions are more forgiving:

>>> from datetime import *
>>> date(1,2,**{u'day':10}), 2, 10)
>>> dict(**{u'x':1,2:3,():5})
{u'x': 1, 2: 3, (): 5}


>>> date(1,2,**{u'day':10,u'x':20})
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: keywords must be strings

I would not advocate making ** completely promiscuous (as in dict(..) 
above), but permitting unicode strings will allow for easier 3.0 

I'll submit a patch.
msg86639 - (view) Author: Daniel Diniz (ajaksu2) * (Python triager) Date: 2009-04-27 01:23
Fixed in  r68805, #4978.
Date User Action Args
2022-04-11 14:56:33adminsetgithub: 46898
2009-04-27 01:23:28ajaksu2setstatus: open -> closed

superseder: allow unicode keyword args

nosy: + ajaksu2
messages: + msg86639
resolution: out of date
stage: resolved
2008-05-13 08:33:57georg.brandlsetpriority: normal
keywords: + 26backport, - patch
2008-04-17 06:13:33loewissetversions: + Python 2.6, - Python 2.5
2008-04-17 05:26:24belopolskysetfiles: + issue2646.diff
2008-04-17 04:43:49belopolskysetnosy: + belopolsky
messages: + msg65572
2008-04-16 22:15:48j5setmessages: + msg65568
2008-04-16 21:40:05j5create