From: Anthony Baxter Date: Wed, 5 Dec 2001 04:39:41 +0000 (+0000) Subject: backport 1.18, 1.19, 1.20: X-Git-Tag: v2.1.2c1~69 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f05af938dc3cd8e075cde6c966f4447a48789d84;p=thirdparty%2FPython%2Fcpython.git backport 1.18, 1.19, 1.20: -- Apply two small changes to the Windows code, according to SF bug #427345. These are supposed to support binary data and avoid buffering problems on Windows. -- SF patch #467430. - replace some log_error() calls with log_message() - flush self.rfile before forking too (hope this works on Windows) -- Fix two typos, one noted by Noah Spurrier in SF bug #475166, the second noted after a second's thought about what the next line should do. :-( --- diff --git a/Lib/CGIHTTPServer.py b/Lib/CGIHTTPServer.py index d6afaa105f3a..e724601098de 100644 --- a/Lib/CGIHTTPServer.py +++ b/Lib/CGIHTTPServer.py @@ -192,6 +192,7 @@ class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): if '=' not in decoded_query: args.append(decoded_query) nobody = nobody_uid() + self.rfile.flush() # Always flush before forking self.wfile.flush() # Always flush before forking pid = os.fork() if pid != 0: @@ -221,17 +222,17 @@ class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): if self.is_python(scriptfile): interp = sys.executable if interp.lower().endswith("w.exe"): - # On Windows, use python.exe, not python.exe - interp = interp[:-5] = interp[-4:] - cmdline = "%s %s" % (interp, cmdline) + # On Windows, use python.exe, not pythonw.exe + interp = interp[:-5] + interp[-4:] + cmdline = "%s -u %s" % (interp, cmdline) if '=' not in query and '"' not in query: cmdline = '%s "%s"' % (cmdline, query) - self.log_error("command: %s", cmdline) + self.log_message("command: %s", cmdline) try: nbytes = int(length) except: nbytes = 0 - fi, fo = os.popen2(cmdline) + fi, fo = os.popen2(cmdline, 'b') if self.command.lower() == "post" and nbytes > 0: data = self.rfile.read(nbytes) fi.write(data) @@ -241,7 +242,7 @@ class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): if sts: self.log_error("CGI script exit status %#x", sts) else: - self.log_error("CGI script exited OK") + self.log_message("CGI script exited OK") else: # Other O.S. -- execute script in this process @@ -266,7 +267,7 @@ class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): except SystemExit, sts: self.log_error("CGI script exit status %s", str(sts)) else: - self.log_error("CGI script exited OK") + self.log_message("CGI script exited OK") nobody = None