[Python-checkins] python/dist/src/Lib CGIHTTPServer.py,1.33,1.34

tim_one at users.sourceforge.net tim_one at users.sourceforge.net
Sat Mar 20 16:51:14 EST 2004


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5208/Lib

Modified Files:
	CGIHTTPServer.py 
Log Message:
SF patch 508730  CGIHTTPServer execfile should save cwd

UNTESTED!!!

This simple two-line patch has been sitting on SF for more than 2 years.
I'm guessing it's because nobody knows how to test it -- I sure don't.
It doesn't look like you can get to this part of the code on Unixish
or Windows systems, so the "how to test it?" puzzle has more than one
part.  OTOH, if this is dead code, it doesn't matter either if I just
broke it <wink>.


Index: CGIHTTPServer.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/CGIHTTPServer.py,v
retrieving revision 1.33
retrieving revision 1.34
diff -C2 -d -r1.33 -r1.34
*** CGIHTTPServer.py	12 Feb 2004 17:35:05 -0000	1.33
--- CGIHTTPServer.py	20 Mar 2004 21:51:12 -0000	1.34
***************
*** 121,125 ****
              return
          if not os.path.isfile(scriptfile):
!             self.send_error(403, "CGI script is not a plain file (%r)" % 
                              scriptname)
              return
--- 121,125 ----
              return
          if not os.path.isfile(scriptfile):
!             self.send_error(403, "CGI script is not a plain file (%r)" %
                              scriptname)
              return
***************
*** 274,277 ****
--- 274,278 ----
              save_stderr = sys.stderr
              try:
+                 save_cwd = os.getcwd()
                  try:
                      sys.argv = [scriptfile]
***************
*** 286,289 ****
--- 287,291 ----
                      sys.stdout = save_stdout
                      sys.stderr = save_stderr
+                     os.chdir(save_cwd)
              except SystemExit, sts:
                  self.log_error("CGI script exit status %s", str(sts))




More information about the Python-checkins mailing list