Open bnbdr opened 7 years ago
Does python 3 allow unicode
headers?
Yes. You can run the sample I provided without issue using python3.
In fact, python 3 will complain if you use bytes
, it seems
Seems reasonable to support the literal-string type of the running python environment;
unicode_literals
changes the type for the caller's module, and not bottle's. My proposed change simply enforces the real literal-type that bottle(and probably the underlying framework) expects.
Bottle expects 'native strings' (str()
type) most of the time. Using from __future__ import unicode_literals
will probably break a lot more than just headers.
Looks strange that header values are converted to Unicode, but keys are only normalized. Added uniform conversion to keys also - issue is gone
Python asserts that header names are StringType, which crashes the code whenever unicode strings are used directly as keys in python 2.x, or when someone uses
unicode_literals
from__future__
in their python 2/3 compatible code.Reproducible sample:
possible solution could be normalizing the key returned from
_hkey