<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hi,<br>
    <br>
    On 14/07/2011 15.57, ezio.melotti wrote:
    <blockquote cite="mid:E1QhLTp-0007zF-Vy@dinsdale.python.org"
      type="cite">
      <pre wrap=""><a class="moz-txt-link-freetext" href="http://hg.python.org/cpython/rev/ac1c3291a689">http://hg.python.org/cpython/rev/ac1c3291a689</a>
changeset:   71325:ac1c3291a689
parent:      71321:f45823977d4b
parent:      71324:530ba6c7e578
user:        Ezio Melotti <a class="moz-txt-link-rfc2396E" href="mailto:ezio.melotti@gmail.com">&lt;ezio.melotti@gmail.com&gt;</a>
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</pre>
    </blockquote>
    <br>
    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.<br>
    <br>
    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].<br>
    <br>
    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.<br>
    <br>
    [0]: <a
      href="http://hg.python.org/cpython/file/ac1c3291a689/Lib/cgi.py#l50">http://hg.python.org/cpython/file/ac1c3291a689/Lib/cgi.py#l50</a><br>
    <br>
    Best Regards,<br>
    Ezio Melotti<br>
    <br>
    <blockquote cite="mid:E1QhLTp-0007zF-Vy@dinsdale.python.org"
      type="cite">
      <pre wrap="">
+            self.addCleanup(log_cleanup)
             cgi.log("Testing log 4")
 
     def test_fieldstorage_readline(self):

</pre>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Python-checkins mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Python-checkins@python.org">Python-checkins@python.org</a>
<a class="moz-txt-link-freetext" href="http://mail.python.org/mailman/listinfo/python-checkins">http://mail.python.org/mailman/listinfo/python-checkins</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>