Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork16.7k
Description
Expected Behavior
I should be able to return a single value from my view(that is, not a tuple) and have my value passed to my custom response class. In this case I have a response class that detects whether JSON or pickle data was requested by the client and dumps the return value appropriately. This allows me to simply return a list or dict from my view without having to detect and dump the appropriate type.
@mod.route('/')defreturn_json_or_pickle():return ['foo','bar','bat']
As of Flask 0.12.2 this worked - make_response would pass the list to my custom response class and my client would get what it wanted.
Actual Behavior
As of 1.0, commit#2256 was merged which added an explicit check to see if the return value was a list; treating a list as a tuple return in that case. I now get a typeerror:
TypeError:The view function did not return a valid response tuple. The tuple must have the form (body, status, headers), (body, status), or (body, headers).
If I change my view function to return a tuple:
@mod.route('/')defreturn_json_or_pickle():return ['foo','bar','bat'],200
the previous functionality is restored! This confirms that tuple handling is of course perfectly fine. I have apull request prepared which should do a very nice job of resolving the issue - it simply omitslist from the type check in make_response. Since a list is not a valid response anyway, there's no reason I can see for it to be there.
Environment
- Python version: 3.6
- Flask version: 1.0
- Werkzeug version: n/a