git » blitiri » commit 17368e6

Fix string vs bytes mismatches

author Alberto Bertogli
2022-08-20 20:06:50 UTC
committer Alberto Bertogli
2022-08-20 20:30:19 UTC
parent a9293e1570aecec6e41cc6d8f5f6b048b3b6eeb0

Fix string vs bytes mismatches

blitiri.cgi +3 -3

diff --git a/blitiri.cgi b/blitiri.cgi
index 053161b..89517df 100755
--- a/blitiri.cgi
+++ b/blitiri.cgi
@@ -510,7 +510,7 @@ def cached(f):
         fname = "blitiri.%s.%s.cache" % (f.__name__, hashes)
         cache_file = os.path.join(cache_path, fname)
         try:
-            s = open(cache_file).read()
+            s = open(cache_file).read().decode("utf8")
         except:
             s = f(*args, **kwargs)
             open(cache_file, "w").write(s)
@@ -531,7 +531,7 @@ def rst_to_html(rst, secure=True):
         "raw_enabled": secure,
     }
     parts = publish_parts(rst, settings_overrides=settings, writer_name="html")
-    return parts["body"].encode("utf8")
+    return parts["body"]
 
 
 def validate_rst(rst, secure=True):
@@ -853,7 +853,7 @@ class Article(object):
         self.path = path
         self.created = created
         self.updated = updated
-        self.uuid = "%08x" % zlib.crc32(self.path)
+        self.uuid = "%08x" % zlib.crc32(self.path.encode("utf8"))
 
         self.loaded = False