Chad Whitacre added the comment:

> in the 3.x version, only character strings (unicode) are accepted
> The code was changed to do this in r83361 #3788.

That seems like a bug to me. It looks like the intention was to avoid the 
`type("")` check for stylistic reasons, so `isinstance(rawdata, str)` is an 
understandable translation under 3.1 (which #3788 targets), but I suspect that 
`type("")` should never have survived the transition to Python 3 in the first 
place. The 2.7 branch still has `type("")` (not `str("")` as originally 
reported):

https://hg.python.org/cpython/file/2.7/Lib/Cookie.py#l639


> “raw” would suggest to me than only bytes make sense.

Agreed. Cookie names and values are constrained to a subset of ASCII:

https://tools.ietf.org/html/rfc6265#section-4.1.1

I suggest cookies be thought of as a binary data store, with programmers 
responsible to encode/decode their data at the boundary with the cookies 
library.


> I would tend to edit the documentation but no[t] the behavior, given that 2.7 
> is stable and this behavior has been present and documented for a long time.

Leaving 2.7 as-is makes sense, but now I think it looks like we have a 
regression in 3, which should be fixed.

----

P.S. I arrived here from https://github.com/gratipay/aspen.py/pull/524.

----------
nosy: +whit537

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue11315>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to