Skip to content

Commit 7a50d44

Browse files
committed
Rework how return is parsed
Explicitly check for list/tuple of length 3
1 parent 8034a81 commit 7a50d44

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

adafruit_wsgi/wsgi_app.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,20 @@ def __call__(self, environ: Dict[str, str], start_response: Callable):
6666

6767
if match:
6868
args, route = match
69-
try:
70-
status, headers, resp_data = route["func"](request, *args)
71-
except TypeError as err:
69+
response_params = route["func"](request, *args)
70+
if (
71+
not (
72+
isinstance(response_params, list)
73+
or isinstance(response_params, tuple)
74+
)
75+
or len(response_params) != 3
76+
):
7277
raise RuntimeError(
7378
"Proper HTTP response return not given for request handler '{}'".format(
7479
route["func"].__name__
7580
)
76-
) from err
77-
81+
)
82+
status, headers, resp_data = response_params
7883
start_response(status, headers)
7984
return resp_data
8085

0 commit comments

Comments
 (0)