Skip to content

Commit 8b4bc05

Browse files
committed
Fix /bytes endpoint with newer werkzeug versions
At some point, werkzeug starting checking the inputs to the write() method, which caused the following traceback: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/werkzeug/serving.py", line 364, in run_wsgi execute(self.server.app) File "/usr/lib/python3/dist-packages/werkzeug/serving.py", line 328, in execute write(data) File "/usr/lib/python3/dist-packages/werkzeug/serving.py", line 296, in write assert isinstance(data, bytes), "applications must write bytes" AssertionError: applications must write bytes Fix this by using bytes instead of bytearray.
1 parent 1f6e049 commit 8b4bc05

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

httpbin/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1449,7 +1449,7 @@ def random_bytes(n):
14491449
response = make_response()
14501450

14511451
# Note: can't just use os.urandom here because it ignores the seed
1452-
response.data = bytearray(random.randint(0, 255) for i in range(n))
1452+
response.data = bytes(random.randint(0, 255) for i in range(n))
14531453
response.content_type = "application/octet-stream"
14541454
return response
14551455

0 commit comments

Comments
 (0)