Skip to content

Commit

Permalink
Fix field2string to always convert to the native string format (and r…
Browse files Browse the repository at this point in the history
…emove the `unicode = str` workaround that is just wrong). This means some other tests might fail now that worked before, but those need better fixes anyway.
  • Loading branch information
dwt authored and hannosch committed May 13, 2017
1 parent 89fd510 commit 440df68
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/ZPublisher/Converters.py
Expand Up @@ -16,18 +16,18 @@
from DateTime import DateTime
from DateTime.interfaces import SyntaxError
from cgi import escape

if sys.version_info >= (3, ):
unicode = str
import six

# This may get overwritten during configuration
default_encoding = 'utf-8'


def field2string(v):
"""Converts value to native strings (so always to `str` no matter which
python version you are on)"""
if hasattr(v, 'read'):
return v.read()
elif isinstance(v, unicode):
elif six.PY2 and isinstance(v, six.text_type):
return v.encode(default_encoding)
else:
return str(v)
Expand Down

0 comments on commit 440df68

Please sign in to comment.