summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--changelog.d/10845.doc1
-rw-r--r--docs/modules/spam_checker_callbacks.md4
2 files changed, 3 insertions, 2 deletions
diff --git a/changelog.d/10845.doc b/changelog.d/10845.doc
new file mode 100644
index 0000000000..a13c845ae6
--- /dev/null
+++ b/changelog.d/10845.doc
@@ -0,0 +1 @@
+Fix some crashes in the Module API example code, by adding JSON encoding/decoding.
diff --git a/docs/modules/spam_checker_callbacks.md b/docs/modules/spam_checker_callbacks.md
index c45eafcc4b..81574a015c 100644
--- a/docs/modules/spam_checker_callbacks.md
+++ b/docs/modules/spam_checker_callbacks.md
@@ -136,9 +136,9 @@ class IsUserEvilResource(Resource):
         self.evil_users = config.get("evil_users") or []
 
     def render_GET(self, request: Request):
-        user = request.args.get(b"user")[0]
+        user = request.args.get(b"user")[0].decode()
         request.setHeader(b"Content-Type", b"application/json")
-        return json.dumps({"evil": user in self.evil_users})
+        return json.dumps({"evil": user in self.evil_users}).encode()
 
 
 class ListSpamChecker: