diff --git a/0001-Fix-bytes-endpoint-with-newer-werkzeug-versions.patch b/0001-Fix-bytes-endpoint-with-newer-werkzeug-versions.patch new file mode 100644 index 0000000..be4e45d --- /dev/null +++ b/0001-Fix-bytes-endpoint-with-newer-werkzeug-versions.patch @@ -0,0 +1,37 @@ +From 8b4bc05fd0b3b0ecd108fceca002934d9a2f0bd3 Mon Sep 17 00:00:00 2001 +From: Scott Talbert +Date: Wed, 10 Jan 2024 00:17:41 -0500 +Subject: [PATCH] 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. +--- + httpbin/core.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/httpbin/core.py b/httpbin/core.py +index a82c1b8..a282789 100644 +--- a/httpbin/core.py ++++ b/httpbin/core.py +@@ -1449,7 +1449,7 @@ def random_bytes(n): + response = make_response() + + # Note: can't just use os.urandom here because it ignores the seed +- response.data = bytearray(random.randint(0, 255) for i in range(n)) ++ response.data = bytes(random.randint(0, 255) for i in range(n)) + response.content_type = "application/octet-stream" + return response + +-- +2.43.0 + diff --git a/python-httpbin.spec b/python-httpbin.spec index 1fff2aa..afe4d8d 100644 --- a/python-httpbin.spec +++ b/python-httpbin.spec @@ -30,6 +30,9 @@ Patch: 0001-Make-flasgger-dep-optional-26.patch # https://github.com/psf/httpbin/pull/34 # Replace use of a deprecated Flask config setting Patch: 0001-Replace-deprecated-JSONIFY_PRETTYPRINT_REGULAR-usage.patch +# https://github.com/psf/httpbin/pull/41 +# Fix /bytes endpoint with newer werkzeug versions +Patch: 0001-Fix-bytes-endpoint-with-newer-werkzeug-versions.patch BuildArch: noarch %description