Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FakeResponse Py2 bug, assumes headers can be decoded to unicode using default encoding #7

Closed
jamadden opened this issue Apr 26, 2017 · 0 comments · Fixed by #8
Closed

Comments

@jamadden
Copy link
Member

On Py2, headers are byte strings, so when getOutput and hence __str__ attempts to encode them, they must first silently be decoded to unicode using the default encoding. If the default encoding is ascii, and the headers contained any non-ascii values (commonly latin-1), this will fail with a UnicodeError.

This came up in porting zope.app.form to zope.app.wsgi.

jamadden added a commit to zopefoundation/zope.app.form that referenced this issue Apr 26, 2017
jamadden added a commit that referenced this issue Apr 26, 2017
Fix the testlayer's ``FakeResponse`` assuming that headers were in
unicode on Python 2, where they should usually be encoded bytes
already. This could lead to UnicodeDecodeError if the headers
contained non-ascii characters. Also make it implement ``__unicode__``
on Python 2 and ``__bytes__`` on Python 3 to ease cross version
testing.

Also add explicit Py3.6 support.

Fixes #7.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant