Search code examples
pythongoogle-app-enginegae-python27

Flask DebuggedApplication causing runtime error on Google App Engine


When I use the code app.wsgi_app = DebuggedApplication(app) which is recommended by https://stackoverflow.com/a/13821624/3164117 and a blog post I get a beautifully formatted error that the Flask debugger displays perfectly. Without that line of code, there is no error and my existing code works fine.

The exact error is:

File "/Users/DanielFranklin/Desktop/etch/etchcode/lib/flask/app.py", line 1969, in __call__
    return self.wsgi_app(environ, start_response)
File "/Users/DanielFranklin/Desktop/etch/etchcode/lib/werkzeug/debug/__init__.py", line 166, in __call__
    if request.args.get('__debugger__') == 'yes':
File "/Users/DanielFranklin/Desktop/etch/etchcode/lib/werkzeug/utils.py", line 71, in __get__
    value = self.func(obj)
File "/Users/DanielFranklin/Desktop/etch/etchcode/lib/werkzeug/wrappers.py", line 429, in args
    cls=self.parameter_storage_class)
File "/Users/DanielFranklin/Desktop/etch/etchcode/lib/werkzeug/urls.py", line 723, in url_decode
    include_empty, errors))
File "/Users/DanielFranklin/Desktop/etch/etchcode/lib/werkzeug/datastructures.py", line 373, in __init__
    for key, value in mapping or ():
File "/Users/DanielFranklin/Desktop/etch/etchcode/lib/werkzeug/urls.py", line 779, in _url_decode_impl
    key = url_unquote_plus(key, charset, errors)
File "/Users/DanielFranklin/Desktop/etch/etchcode/lib/werkzeug/urls.py", line 545, in url_unquote_plus
    return url_unquote(s, charset, errors)
File "/Users/DanielFranklin/Desktop/etch/etchcode/lib/werkzeug/urls.py", line 522, in url_unquote
    rv = _unquote_to_bytes(string, unsafe)
File "/Users/DanielFranklin/Desktop/etch/etchcode/lib/werkzeug/urls.py", line 351, in _unquote_to_bytes
    if isinstance(string, text_type):
RuntimeError: maximum recursion depth exceeded while calling a Python object

Solution

  • As in the post you quote, it should be app.wsgi_app = DebuggedApplication(app.wsgi_app, True), NOT, as you say, app.wsgi_app = DebuggedApplication(app) -- note that you forgot the True 2nd arg (minor issue, I think) and more cogently that you're wrapping app itself, instead of wrapping app.wsgi_app as you should -- and the latter mistake you made does indeed seem likely to cause the run-away recursion you observe.