Done: changeset: 71337:66e519792e4c tag: tip user: Victor Stinner <victor.stinner at haypocalc.com> date: Thu Jul 14 22:28:36 2011 +0200 files: Lib/cgi.py Lib/test/test_cgi.py Misc/NEWS description: Add cgi.closelog() function to close the log file Le 14/07/2011 14:57, Ezio Melotti a écrit : > >> 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,
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4