diff options
author | Tim Peters <tim.peters@gmail.com> | 2004-03-20 21:51:12 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2004-03-20 21:51:12 (GMT) |
commit | 27f49610afe5ca8fdce780490ec22def39bbbe3c (patch) | |
tree | 9bbbd2f3950689d391c36cd05d7090083ac48567 | |
parent | 9dbf9084e89eccc89db903e70560074466be2c4c (diff) | |
download | cpython-27f49610afe5ca8fdce780490ec22def39bbbe3c.zip cpython-27f49610afe5ca8fdce780490ec22def39bbbe3c.tar.gz cpython-27f49610afe5ca8fdce780490ec22def39bbbe3c.tar.bz2 |
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>.
-rw-r--r-- | Lib/CGIHTTPServer.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/CGIHTTPServer.py b/Lib/CGIHTTPServer.py index 52e04e9..9e118b2 100644 --- a/Lib/CGIHTTPServer.py +++ b/Lib/CGIHTTPServer.py @@ -120,7 +120,7 @@ class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): self.send_error(404, "No such CGI script (%r)" % scriptname) return if not os.path.isfile(scriptfile): - self.send_error(403, "CGI script is not a plain file (%r)" % + self.send_error(403, "CGI script is not a plain file (%r)" % scriptname) return ispy = self.is_python(scriptname) @@ -273,6 +273,7 @@ class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): save_stdout = sys.stdout save_stderr = sys.stderr try: + save_cwd = os.getcwd() try: sys.argv = [scriptfile] if '=' not in decoded_query: @@ -285,6 +286,7 @@ class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): sys.stdin = save_stdin 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)) else: |