devashishbcsingh / modwsgi

Automatically exported from code.google.com/p/modwsgi
0 stars 0 forks source link

environ['wsgi.errors'] .writelines not works #254

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago

Just try:
environ['wsgi.errors'].writelines(('abc', 'efg'))

Log_wrintelines@mod_wsgi.c: 

    while ((item = PyIter_Next(iterator))) {
        PyObject *result = NULL;

-        result = Log_write(self, item);
+        msg = PyString_AsString(item);

someting like that~

Original issue reported on code.google.com by kofreestyler on 27 Dec 2011 at 11:09

GoogleCodeExporter commented 8 years ago
What version of Python are you using?

Original comment by Graham.Dumpleton@gmail.com on 27 Dec 2011 at 11:15

GoogleCodeExporter commented 8 years ago
Also provide the exact error message you are currently getting in any exception 
raised.

Original comment by Graham.Dumpleton@gmail.com on 27 Dec 2011 at 11:17

GoogleCodeExporter commented 8 years ago
The correct fix is:

--- a/mod_wsgi/mod_wsgi.c   Tue Nov 29 16:30:24 2011 +1100
+++ b/mod_wsgi/mod_wsgi.c   Tue Dec 27 22:25:23 2011 +1100
@@ -1515,8 +1515,14 @@

     while ((item = PyIter_Next(iterator))) {
         PyObject *result = NULL;
-
-        result = Log_write(self, item);
+        PyObject *args = NULL;
+
+        args = PyTuple_Pack(1, item);
+
+        result = Log_write(self, args);
+
+        Py_DECREF(args);
+        Py_DECREF(item);

         if (!result) {
             Py_DECREF(iterator);

There was also a memory leak in there as object returned from iterator didn't 
have its reference count decremented.

Original comment by Graham.Dumpleton@gmail.com on 27 Dec 2011 at 11:27

GoogleCodeExporter commented 8 years ago
This change was already made in mod_wsgi trunk for 4.0.

Original comment by Graham.Dumpleton@gmail.com on 19 Mar 2012 at 9:47

GoogleCodeExporter commented 8 years ago

Original comment by Graham.Dumpleton@gmail.com on 28 Mar 2013 at 6:30