You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mod_python-commits@quetz.apache.org by gr...@apache.org on 2006/04/13 13:22:03 UTC
svn commit: r393785 - in /httpd/mod_python/branches/3.2.x: Doc/appendixc.tex
src/mod_python.c
Author: grahamd
Date: Thu Apr 13 04:22:00 2006
New Revision: 393785
URL: http://svn.apache.org/viewcvs?rev=393785&view=rev
Log:
Backported additional debug logging when mod_python startup problems occur
as associated with MODPYTHON-158 from trunk to branches/3.2.x.
Modified:
httpd/mod_python/branches/3.2.x/Doc/appendixc.tex
httpd/mod_python/branches/3.2.x/src/mod_python.c
Modified: httpd/mod_python/branches/3.2.x/Doc/appendixc.tex
URL: http://svn.apache.org/viewcvs/httpd/mod_python/branches/3.2.x/Doc/appendixc.tex?rev=393785&r1=393784&r2=393785&view=diff
==============================================================================
--- httpd/mod_python/branches/3.2.x/Doc/appendixc.tex (original)
+++ httpd/mod_python/branches/3.2.x/Doc/appendixc.tex Thu Apr 13 04:22:00 2006
@@ -47,6 +47,11 @@
\item
(\citetitle[http://issues.apache.org/jira/browse/MODPYTHON-93]{MODPYTHON-93})
Improved util.FieldStorage efficiency.
+ \item
+ (\citetitle[http://issues.apache.org/jira/browse/MODPYTHON-158]{MODPYTHON-158})
+ Added additional debugging and logging output for where mod_python
+ cannot initialise itself properly due to Python or mod_python version
+ mismatches or missing Python module code files.
\end{itemize}
Bug Fixes
Modified: httpd/mod_python/branches/3.2.x/src/mod_python.c
URL: http://svn.apache.org/viewcvs/httpd/mod_python/branches/3.2.x/src/mod_python.c?rev=393785&r1=393784&r2=393785&view=diff
==============================================================================
--- httpd/mod_python/branches/3.2.x/src/mod_python.c (original)
+++ httpd/mod_python/branches/3.2.x/src/mod_python.c Thu Apr 13 04:22:00 2006
@@ -80,7 +80,7 @@
static PyObject * make_obcallback(char *name, server_rec *s)
{
- PyObject *m;
+ PyObject *m = NULL;
PyObject *obCallBack = NULL;
/* This makes _apache appear imported, and subsequent
@@ -97,18 +97,68 @@
*/
if (! ((m = PyImport_ImportModule(MODULENAME)))) {
+ PyObject *path;
+
ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, s,
- "make_obcallback: could not import %s.\n", (!MODULENAME) ? "<null>" : MODULENAME);
+ "make_obcallback: could not import %s.\n",
+ (!MODULENAME) ? "<null>" : MODULENAME);
+
PyErr_Print();
fflush(stderr);
+
+ path = PyObject_Repr(PySys_GetObject("path"));
+
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, s,
+ "make_obcallback: Python path being used \"%s\".",
+ PyString_AsString(path));
+
+ Py_DECREF(path);
+
+ return NULL;
}
- if (m && ! ((obCallBack = PyObject_CallMethod(m, INITFUNC, "sO", name, MpServer_FromServer(s))))) {
+ if (m && ! ((obCallBack = PyObject_CallMethod(m,
+ INITFUNC, "sO", name, MpServer_FromServer(s))))) {
+
+ const char *mp_compile_version = MPV_STRING;
+ const char *mp_dynamic_version = "<unknown>";
+ PyObject *o = NULL;
+ PyObject *d = NULL;
+ PyObject *f = NULL;
+
ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, s,
- "make_obcallback: could not call %s.\n", (!INITFUNC) ? "<null>" : INITFUNC);
+ "make_obcallback: could not call %s.\n",
+ (!INITFUNC) ? "<null>" : INITFUNC);
+
PyErr_Print();
fflush(stderr);
+
+ m = PyImport_ImportModule("mod_python");
+ if (m) {
+ d = PyModule_GetDict(m);
+ o = PyDict_GetItemString(d, "version");
+ f = PyDict_GetItemString(d, "__file__");
+
+ if (o) {
+ mp_dynamic_version = PyString_AsString(o);
+ }
+ }
+
+ if (strcmp(mp_compile_version, mp_dynamic_version) != 0) {
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, s,
+ "make_obcallback: mod_python version mismatch, expected '%s', found '%s'.",
+ mp_compile_version, mp_dynamic_version);
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, s,
+ "make_obcallback: mod_python modules location '%s'.",
+ PyString_AsString(f));
+ }
+
+ Py_XDECREF(o);
+ Py_XDECREF(d);
+ Py_XDECREF(f);
}
+
+ Py_XDECREF(m);
return obCallBack;
}
@@ -561,6 +611,9 @@
const char *userdata_key = "python_init";
apr_status_t rc;
+ const char *py_compile_version = PY_VERSION;
+ const char *py_dynamic_version = 0;
+
/* The "initialized" flag is a fudge for Mac OS X. It
* addresses two issues. The first is that when an Apache
* "restart" is performed, Apache will unload the mod_python
@@ -585,9 +638,23 @@
/* mod_python version */
ap_add_version_component(p, VERSION_COMPONENT);
-
+
+ py_dynamic_version = strtok((char *)Py_GetVersion(), " ");
+
+ if (strcmp(py_compile_version, py_dynamic_version) != 0) {
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, s,
+ "python_init: Python version mismatch, expected '%s', found '%s'.",
+ py_compile_version, py_dynamic_version);
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, s,
+ "python_init: Python executable found '%s'.",
+ Py_GetProgramFullPath());
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, s,
+ "python_init: Python path being used '%s'.",
+ Py_GetPath());
+ }
+
/* Python version */
- sprintf(buff, "Python/%.200s", strtok((char *)Py_GetVersion(), " "));
+ sprintf(buff, "Python/%.200s", py_dynamic_version);
ap_add_version_component(p, buff);
/* global config */