classification
Title: cannot assign unicode keys to SimpleCookie
Type: behavior Stage:
Components: Library (Lib) Versions: Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: flox, r.david.murray
Priority: normal Keywords:

Created on 2013-05-19 14:17 by flox, last changed 2013-05-19 14:49 by flox. This issue is now closed.

Messages (3)
msg189595 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2013-05-19 14:17
from Cookie import SimpleCookie

cookie = SimpleCookie()
cookie[u'apple'] = u'green'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/Cookie.py", line 592, in __setitem__
    self.__set(key, rval, cval)
  File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/Cookie.py", line 585, in __set
    M.set(key, real_value, coded_value)
  File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/Cookie.py", line 459, in set
    if "" != translate(key, idmap, LegalChars):
  File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/string.py", line 493, in translate
    return s.translate(table, deletions)
TypeError: translate() takes exactly one argument (2 given)



The documentation don't say it's not supported.
And the error TypeError seems not appropriate.
msg189596 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2013-05-19 14:25
Python2 tends to document where unicode *is* supported, rather than where it is not.  And why would a TypeError be incorrect if the unicode type is not supported?

I do not think it likely that this falls into the 'bug' category at this point in the Python2 lifecycle.
msg189598 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2013-05-19 14:49
you're right, this behavior is documented.

>>> u'read this short text'.translate(None, 'aeiou')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: translate() takes exactly one argument (2 given)
>>> 

http://docs.python.org/2/library/stdtypes.html#str.translate
History
Date User Action Args
2013-05-19 14:49:51floxsetstatus: open -> closed
resolution: not a bug
messages: + msg189598
2013-05-19 14:25:58r.david.murraysetnosy: + r.david.murray
messages: + msg189596
2013-05-19 14:17:57floxcreate