]> www.dolda2000.com Git - ashd.git/commitdiff
python: Replace ByteString with Buffer, for future Python compatibility. master
authorFredrik Tolf <fredrik@dolda2000.com>
Tue, 10 Nov 2026 16:41:35 +0000 (17:41 +0100)
committerFredrik Tolf <fredrik@dolda2000.com>
Tue, 10 Nov 2026 16:41:35 +0000 (17:41 +0100)
python/ashd-wsgi3
python/ashd/perf.py
python/ashd/util.py
python/scgi-wsgi3

index 656e2ae4c02d11457ef73dea23477f8172e0ee8d..fc95d1f5e7a65d4996a44811a1774495ffe2aacc 100755 (executable)
@@ -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")
index 4adfc54f9a25bf3a674e7909581375b7de06a400..8b2dd796abde1afe850a9f16dcab90689c91805c 100644 (file)
@@ -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)
index bf32637c83262f0740041e971ad8c2d78ceff675..b9164546ce4c9f111763550f364b620f2c54cb9d 100644 (file)
@@ -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)
index 484e9196bfa67df17cd3133709cc34e368fcccca..70a8822d7978a62bd89b18f43b6d60a93e2707bb 100755 (executable)
@@ -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")