diff --git a/lib/python/mod_python/apache.py b/lib/python/mod_python/apache.py index 6ef72aef..56cd10ac 100644 --- a/lib/python/mod_python/apache.py +++ b/lib/python/mod_python/apache.py @@ -26,8 +26,11 @@ import stat import imp import types -import cgi import _apache +try: + from html import escape +except: + from cgi import escape try: import threading @@ -549,7 +552,7 @@ def ReportError(self, etype, evalue, etb, req=None, filter=None, srv=None, s = '\n
\nMod_python error: "%s %s"\n\n' % (phase, hname)
for e in traceback.format_exception(etype, evalue, etb):
- s = s + cgi.escape(e) + '\n'
+ s = s + escape(e) + '\n'
s = s + "\n"
if filter:
diff --git a/lib/python/mod_python/util.py b/lib/python/mod_python/util.py
index 3020f95d..bf9e6775 100644
--- a/lib/python/mod_python/util.py
+++ b/lib/python/mod_python/util.py
@@ -156,7 +156,10 @@ class StringField(bytes):
disp_options = None
def __new__(self, value):
- return bytes.__new__(self, str(value), "utf-8")
+ if PY2:
+ return bytes.__new__(self, value)
+ else:
+ return bytes.__new__(self, str(value), encoding = "utf-8")
def __init__(self, value):
self.value = value
diff --git a/src/_apachemodule.c b/src/_apachemodule.c
index 816f77de..e8615764 100644
--- a/src/_apachemodule.c
+++ b/src/_apachemodule.c
@@ -24,7 +24,7 @@
#include "mod_python.h"
-/* A referende to the _apache.SERVER_RETURN */
+/* A reference to the _apache.SERVER_RETURN */
PyObject *Mp_ServerReturn;