Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

make_response changes breaks custom response class #2736

Closed
Milestone
@jesseops

Description

@jesseops

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2026 Movatter.jp