Closed altbdoor closed 8 years ago
It would appear so, but I'm happy to accept a pull request to allow it to support both.
(We should probably look to how flask/werkzeug handles this)
@jonparrott I have tried to reproduce this bug on python 3. I wrote similar app and installed webapp2, but without of gae sdk. And I didn't encounter with the same error when I tried to run app.
There are were an errors with compatibility between python 2 and 3, but the same bug it wasn't.
I resolved compatibility errors in webapp2
and webapp2_extras/local.py
and app started.
If this trouble exists in gae sdk, so I'm afraid, that I will not can help here
@mymtwcom, thank you very much for your investigation. I tried looking into the GAE source code as well, and I found the following on /google/appengine/runtime/wsgi.py
, line 194, as described in the stack trace.
if not isinstance(name, str):
raise InvalidResponseError('header names must be str, got %r (%r)' %
(_GetTypeName(name), name))
I would assume that webapp2 and webob are both returning proper, valid responses, but only GAE is complaining about the data type.
I searched in GAE's issues page, only to find a similar ticket opened since 2012.
Sorry for all the trouble @mymtwcom and @jonparrott, for mistaking this as a webapp2 issue. I will take this to GAE's issue tracker.
@altbdoor thx for your response too, I'm afraid, that they will not fix this bug soon(near future) :))) Off-topic @jonparrott Does webapp2 currently needs in PR for versions compatibility of python 2-3, even if it will not fix current issue(bug)?? (cuz the trouble was in GAE)
I can prod on accepting unicode headers internally, but I think it's unlikely to see that change. As such, I'm going to close this issue.
Does webapp2 currently needs in PR for versions compatibility of python 2-3, even if it will not fix current issue(bug)?? (cuz the trouble was in GAE)
Absolutely, webapp2 doesn't just run on App Engine. I'm happy to review and accept any contributions to support Python 3.
I am writing Py3 compatible code, so I usually import
unicode_literals
at the top of each.py
file. In one of the handler methods, I am trying to change the response headers to serveContent-Type: application/json
.I am using the latest GAE SDK for Python (1.9.40 - 2016-07-15), and I encountered the error below.
This seems to be the issue with
self.response.headers['Access-Control-Allow-Origin'] = '*'
as well. Does webapp2 only accept byte strings for response headers?