Flask DebuggedApplication 在 Google App Engine 上导致运行时错误

Flask DebuggedApplication causing runtime error on Google App Engine

当我使用 and a blog post 推荐的代码 app.wsgi_app = DebuggedApplication(app) 时,我得到了 Flask 调试器完美显示的格式精美的错误。没有那行代码,没有错误,我现有的代码工作正常。

准确的错误是:

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

如您所引用的 post,它应该是 app.wsgi_app = DebuggedApplication(app.wsgi_app, True) 而不是 ,如您所说,app.wsgi_app = DebuggedApplication(app) -- 请注意你忘记了 True 第二个参数(我认为是小问题) 并且 更有说服力的是你正在包装 app 本身,而不是包装 app.wsgi_app正如你应该做的那样——你犯的后一个错误确实看起来很可能导致你观察到的 run-away 递归。