diff --git a/docs/release-notes/version-4.4.15.rst b/docs/release-notes/version-4.4.15.rst index e638b99e..e7af61fb 100644 --- a/docs/release-notes/version-4.4.15.rst +++ b/docs/release-notes/version-4.4.15.rst @@ -9,3 +9,11 @@ Version 4.4.15 of mod_wsgi can be obtained from: For details on the availability of Windows binaries see: https://github.com/GrahamDumpleton/mod_wsgi/tree/master/win32 + +Bugs Fixed +---------- + +1. When specifying multiple directories for the Python module search path +using the ``WSGIPythonPath`` directive, or the ``python-path`` option to +``WSGIDaemonProcess``, it was failing under Python 3 due to incorrect +logging. It was therefore only possible to add a single directory. diff --git a/src/server/wsgi_interp.c b/src/server/wsgi_interp.c index b3ea19a9..01f6bb3f 100644 --- a/src/server/wsgi_interp.c +++ b/src/server/wsgi_interp.c @@ -843,16 +843,14 @@ InterpreterObject *newInterpreterObject(const char *name) if (end) { #if PY_MAJOR_VERSION >= 3 - item = PyUnicode_Decode(start, end-start, - Py_FileSystemDefaultEncoding, - "surrogateescape"); + item = PyUnicode_DecodeFSDefaultAndSize(start, end-start); + value = PyUnicode_AsUTF8(item); #else item = PyString_FromStringAndSize(start, end-start); + value = PyString_AsString(item); #endif start = end+1; - value = PyString_AsString(item); - Py_BEGIN_ALLOW_THREADS ap_log_error(APLOG_MARK, APLOG_INFO, 0, wsgi_server, "mod_wsgi (pid=%d): Adding '%s' to " @@ -879,16 +877,15 @@ InterpreterObject *newInterpreterObject(const char *name) while (result && end) { #if PY_MAJOR_VERSION >= 3 - item = PyUnicode_Decode(start, end-start, - Py_FileSystemDefaultEncoding, - "surrogateescape"); + item = PyUnicode_DecodeFSDefaultAndSize(start, + end-start); + value = PyUnicode_AsUTF8(item); #else item = PyString_FromStringAndSize(start, end-start); + value = PyString_AsString(item); #endif start = end+1; - value = PyString_AsString(item); - Py_BEGIN_ALLOW_THREADS ap_log_error(APLOG_MARK, APLOG_INFO, 0, wsgi_server, "mod_wsgi (pid=%d): Adding '%s' to " @@ -916,13 +913,21 @@ InterpreterObject *newInterpreterObject(const char *name) } } +#if PY_MAJOR_VERSION >= 3 + item = PyUnicode_DecodeFSDefault(start); + value = PyUnicode_AsUTF8(item); +#else + item = PyString_FromString(start); + value = PyString_AsString(item); +#endif + Py_BEGIN_ALLOW_THREADS ap_log_error(APLOG_MARK, APLOG_INFO, 0, wsgi_server, "mod_wsgi (pid=%d): Adding '%s' to " - "path.", getpid(), start); + "path.", getpid(), value); Py_END_ALLOW_THREADS - args = Py_BuildValue("(s)", start); + args = Py_BuildValue("(O)", item); result = PyEval_CallObject(object, args); if (!result) { @@ -935,6 +940,7 @@ InterpreterObject *newInterpreterObject(const char *name) } Py_XDECREF(result); + Py_XDECREF(item); Py_DECREF(args); Py_DECREF(object);