diff --git a/lib/galaxy/web/framework/middleware/error.py b/lib/galaxy/web/framework/middleware/error.py index 86e1738efe7..93daa1c1c36 100644 --- a/lib/galaxy/web/framework/middleware/error.py +++ b/lib/galaxy/web/framework/middleware/error.py @@ -267,7 +267,7 @@ class CatchingIter: if not self.start_checker.response_started: self.start_checker("500 Internal Server Error", [("content-type", "text/html")], exc_info) - return response + return response.encode("utf-8", errors="ignore") def close(self): # This should at least print something to stderr if the diff --git a/lib/galaxy/web/framework/middleware/profile.py b/lib/galaxy/web/framework/middleware/profile.py index 672c90d4154..7bfeed86907 100644 --- a/lib/galaxy/web/framework/middleware/profile.py +++ b/lib/galaxy/web/framework/middleware/profile.py @@ -67,7 +67,7 @@ class ProfileMiddleware: prof = cProfile.Profile() prof.runctx("run_app()", globals(), locals()) # Build up body with stats - body = "".join(body) + body = b"".join(body) headers = catch_response[1] content_type = response.header_value(headers, "content-type") if not content_type.startswith("text/html"): @@ -77,7 +77,7 @@ class ProfileMiddleware: stats.strip_dirs() stats.sort_stats("time", "calls") output = pstats_as_html(stats, self.limit) - body += template % output + body += (template % output).encode("utf-8") return [body] diff --git a/lib/galaxy/web/framework/middleware/static.py b/lib/galaxy/web/framework/middleware/static.py index 432c6084189..b7f9da7b85f 100644 --- a/lib/galaxy/web/framework/middleware/static.py +++ b/lib/galaxy/web/framework/middleware/static.py @@ -54,7 +54,7 @@ class CacheableStaticURLParser(StaticURLParser): headers: list[tuple[str, str]] = [] ETAG.update(headers, mytime) start_response("304 Not Modified", headers) - return [""] # empty body + return [b""] # empty body app = FileApp(full) if self.cache_seconds: app.cache_control(max_age=int(self.cache_seconds))