File mod_python-3.5.0-do-not-load-site-py.patch of Package apache2-mod_python
From 5bb5d6d0113f6bbd72966a5c1f3e6d40c2e9c8fd Mon Sep 17 00:00:00 2001
From: Grisha Trubetskoy <grisha@modpython.org>
Date: Tue, 1 Dec 2015 22:07:50 -0500
Subject: [PATCH] Do not import site.py for the main interpreter. Fixes #46.
---
src/mod_python.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/mod_python.c b/src/mod_python.c
index 8c33c04..7e0ef1e 100644
--- a/src/mod_python.c
+++ b/src/mod_python.c
@@ -775,8 +775,15 @@ static int python_init(apr_pool_t *p, apr_pool_t *ptemp,
{
initialized = 1;
- /* initialze the interpreter */
+ /* Initialze the main interpreter. We do not want site.py to
+ * be imported because as of Python 2.7.9 it would cause a
+ * circular dependency related to _locale which breaks
+ * graceful restart so we set Py_NoSiteFlag to 1 just for this
+ * one time. (https://github.com/grisha/mod_python/issues/46)
+ */
+ Py_NoSiteFlag = 1;
Py_Initialize();
+ Py_NoSiteFlag = 0;
#ifdef WITH_THREAD
/* create and acquire the interpreter lock */
@@ -2649,7 +2656,7 @@ static void PythonChildInitHandler(apr_pool_t *p, server_rec *s)
* problems as well. Thus disable cleanup of Python when
* child processes are being shutdown. (MODPYTHON-109)
*
- apr_pool_cleanup_register(p, NULL, python_finalize, apr_pool_cleanup_null);
+ * apr_pool_cleanup_register(p, NULL, python_finalize, apr_pool_cleanup_null);
*/
/*