From: Fredrik Tolf Date: Tue, 10 Nov 2026 16:41:35 +0000 (+0100) Subject: python: Replace ByteString with Buffer, for future Python compatibility. X-Git-Url: http://git.dolda2000.com/gitweb/?a=commitdiff_plain;h=HEAD;p=ashd.git python: Replace ByteString with Buffer, for future Python compatibility. --- diff --git a/python/ashd-wsgi3 b/python/ashd-wsgi3 index 656e2ae..fc95d1f 100755 --- a/python/ashd-wsgi3 +++ b/python/ashd-wsgi3 @@ -154,7 +154,7 @@ def mkenv(req): return env def recode(thing): - if isinstance(thing, collections.abc.ByteString): + if isinstance(thing, collections.abc.Buffer): return thing else: return str(thing).encode("utf-8") diff --git a/python/ashd/perf.py b/python/ashd/perf.py index 4adfc54..8b2dd79 100644 --- a/python/ashd/perf.py +++ b/python/ashd/perf.py @@ -56,7 +56,7 @@ class request(object): try: if len(self.resp) > 0: status = self.resp[0] - if isinstance(status, collections.abc.ByteString): + if isinstance(status, collections.abc.Buffer): status = status.decode("latin-1") else: status = str(status) diff --git a/python/ashd/util.py b/python/ashd/util.py index bf32637..b916454 100644 --- a/python/ashd/util.py +++ b/python/ashd/util.py @@ -4,7 +4,7 @@ This module implements a rather convenient interface for writing ashd handlers, wrapping the low-level ashd.proto module. """ -import os, socket, collections +import os, socket, collections.abc from . import proto __all__ = ["stdfork", "pchild", "respond", "serveloop"] @@ -132,7 +132,7 @@ def respond(req, body, status = ("200 OK"), ctype = "text/html"): For example: respond(req, "Not found", status = "404 Not Found", ctype = "text/plain") """ - if isinstance(body, collections.ByteString): + if isinstance(body, collections.abc.Buffer): body = bytes(body) else: body = str(body) diff --git a/python/scgi-wsgi3 b/python/scgi-wsgi3 index 484e919..70a8822 100755 --- a/python/scgi-wsgi3 +++ b/python/scgi-wsgi3 @@ -1,6 +1,6 @@ #!/usr/bin/python3 -import sys, os, getopt, logging, collections +import sys, os, getopt, logging, collections.abc import socket import ashd.scgi, ashd.serve try: @@ -99,7 +99,7 @@ def mkenv(head, sk): return env def recode(thing): - if isinstance(thing, collections.ByteString): + if isinstance(thing, collections.abc.Buffer): return thing else: return str(thing).encode("latin-1")