Hi,

On 14/07/2011 15.57, ezio.melotti wrote:
http://hg.python.org/cpython/rev/ac1c3291a689
changeset:   71325:ac1c3291a689
parent:      71321:f45823977d4b
parent:      71324:530ba6c7e578
user:        Ezio Melotti <ezio.melo...@gmail.com>
date:        Thu Jul 14 15:57:12 2011 +0300
summary:
  Merge with 3.2.

files:
  Lib/test/test_cgi.py |  8 +++++++-
  1 files changed, 7 insertions(+), 1 deletions(-)


diff --git a/Lib/test/test_cgi.py b/Lib/test/test_cgi.py
--- a/Lib/test/test_cgi.py
+++ b/Lib/test/test_cgi.py
@@ -155,7 +155,13 @@
             cgi.logfp = None
             cgi.logfile = "/dev/null"
             cgi.initlog("%s", "Testing log 3")
-            self.addCleanup(cgi.logfp.close)
+            def log_cleanup():
+                """Restore the global state of the log vars."""
+                cgi.logfile = ''
+                cgi.logfp.close()
+                cgi.logfp = None
+                cgi.log = cgi.initlog

It was suggested (on #python-dev) to move this function to the cgi module itself, but since I'm not familiar with it I just added it here in order to fix a failure in the test.

The cgi module has two global vars (logfile and logfp) and a global function (log) that is initialized to initlog and then reassigned to either dolog or nolog (a dummy function that does nothing) in initlog itself[0].

If someone thinks the log_cleanup function should be moved to the cgi.py module and/or the code be refactored a bit, he can do it or open an issue.

[0]: http://hg.python.org/cpython/file/ac1c3291a689/Lib/cgi.py#l50

Best Regards,
Ezio Melotti

+            self.addCleanup(log_cleanup)
             cgi.log("Testing log 4")
 
     def test_fieldstorage_readline(self):



_______________________________________________
Python-checkins mailing list
python-check...@python.org
http://mail.python.org/mailman/listinfo/python-checkins

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to