Done:
changeset: 71337:66e519792e4c
tag: tip
user: Victor Stinner <victor.stin...@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,
_______________________________________________
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