classification
Title: allow unicode keyword args
Type: behavior Stage: patch review
Components: Interpreter Core Versions: Python 2.7, Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: benjamin.peterson Nosy List: amaury.forgeotdarc, barry, benjamin.peterson
Priority: release blocker Keywords: needs review, patch

Created on 2009-01-17 23:07 by benjamin.peterson, last changed 2010-02-06 19:17 by benjamin.peterson. This issue is now closed.

Files
File name Uploaded Description Edit
unicode_kwds.patch benjamin.peterson, 2009-01-17 23:30
unicode_keyword_args.patch benjamin.peterson, 2009-01-19 19:19
unicode_kwargs3.patch benjamin.peterson, 2009-01-20 01:20
py26-backport.patch barry, 2010-02-04 09:27
Messages (12)
msg80060 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2009-01-17 23:07
This allows unicode arguments to be passed as keywords to functions to
help "from __future__ import unicode_literals". See
http://mail.python.org/pipermail/python-dev/2009-January/085113.html.
msg80200 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2009-01-19 18:10
The patch works when the unicode contains only ascii, but crashes with
the following input:

>>> def f(hehe): return 42
... 
>>> f(**{u'hehe': 1})
42
>>> f(**{u'héhé': 1})
Segmentation fault

The two PyString_AsString(keyword) calls are now wrong and should be
changed.
msg80206 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2009-01-19 19:19
This patch should fix that.
msg80217 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2009-01-19 23:05
Sorry, but _PyUnicode_AsDefaultEncodedString returns either a borrowed reference (if 
errors==NULL) or a new reference (if errors!=NULL).
In either case it's wrong to DECREF the string when you simply take the buffer's 
address:

>>> f(**{u'someLongString':2})
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: f() got an unexpected keyword argument 'ÛÛÛÛÛÛÛgString'
msg80232 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2009-01-20 01:20
Interesting, I didn't know that about _PyUnicode_AsDefaultEncodedString.
Here's another patch.
msg80240 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2009-01-20 09:40
The patch looks good now.
msg80255 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2009-01-20 14:21
Thanks for the reviews! Applied in r68805.
msg98816 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2010-02-04 09:27
Really trivial back port of r68805 from trunk.
msg98821 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2010-02-04 09:54
release blocker for 2.6.5
msg98823 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2010-02-04 10:12
Why backport? Isn't this a new feature?
msg98825 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2010-02-04 10:33
Maybe not.  It's arguably a bug that adding unicode_literals breaks keyword arguments.  Guido seems to (mostly) agree that it's a bug we just never got around to fixing.

http://www.mail-archive.com/python-dev@python.org/msg45346.html
msg98954 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2010-02-06 19:17
Done in r78027.
History
Date User Action Args
2010-02-06 19:17:45benjamin.petersonsetstatus: open -> closed
resolution: fixed
messages: + msg98954
2010-02-04 10:33:01barrysetmessages: + msg98825
2010-02-04 10:12:54amaury.forgeotdarcsetmessages: + msg98823
2010-02-04 09:54:15barrysetpriority: release blocker

messages: + msg98821
2010-02-04 09:27:53barrysetstatus: closed -> open
files: + py26-backport.patch

assignee: benjamin.peterson
keywords: + needs review
stage: patch review
versions: + Python 2.6
resolution: accepted -> (no value)
messages: + msg98816
components: + Interpreter Core, - Library (Lib)
type: enhancement -> behavior
2010-02-04 09:11:27barrysetnosy: + barry
2009-04-27 01:23:28ajaksu2linkissue2646 superseder
2009-01-20 14:21:45benjamin.petersonsetstatus: open -> closed
resolution: accepted
messages: + msg80255
2009-01-20 09:40:32amaury.forgeotdarcsetmessages: + msg80240
2009-01-20 01:20:11benjamin.petersonsetfiles: + unicode_kwargs3.patch
messages: + msg80232
2009-01-19 23:05:06amaury.forgeotdarcsetmessages: + msg80217
2009-01-19 19:19:19benjamin.petersonsetfiles: + unicode_keyword_args.patch
messages: + msg80206
2009-01-19 18:10:30amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg80200
2009-01-17 23:30:50benjamin.petersonsetfiles: + unicode_kwds.patch
keywords: + patch
2009-01-17 23:07:25benjamin.petersoncreate