[Python-Dev] [Python-checkins] cpython (merge 3.2 -> default): Merge with 3.2.

Victor Stinner victor.stinner at haypocalc.com
Thu Jul 14 22:33:09 CEST 2011


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,



More information about the Python-Dev mailing list

AltStyle によって変換されたページ (->オリジナル) /