[Python-checkins] bpo-40094: CGIHTTPRequestHandler logs exit code (GH-19285)

Victor Stinner webhook-mailer at python.org
Wed Apr 1 21:42:10 EDT 2020


https://github.com/python/cpython/commit/9a679a0e47d58aa73b7747d4e16140048c10baf5
commit: 9a679a0e47d58aa73b7747d4e16140048c10baf5
branch: master
author: Victor Stinner <vstinner at python.org>
committer: GitHub <noreply at github.com>
date: 2020-04-02T03:42:05+02:00
summary:

bpo-40094: CGIHTTPRequestHandler logs exit code (GH-19285)

CGIHTTPRequestHandler of http.server now logs the CGI script exit
code, rather than the CGI script exit status of os.waitpid().

For example, if the script is killed by signal 11, it now logs:
"CGI script exit code -11."

files:
A Misc/NEWS.d/next/Library/2020-04-02-01-13-28.bpo-40094.AeZ34K.rst
M Lib/http/server.py

diff --git a/Lib/http/server.py b/Lib/http/server.py
index 2d74b95586cff..fa204fbc15e3d 100644
--- a/Lib/http/server.py
+++ b/Lib/http/server.py
@@ -1164,8 +1164,9 @@ def run_cgi(self):
                 while select.select([self.rfile], [], [], 0)[0]:
                     if not self.rfile.read(1):
                         break
-                if sts:
-                    self.log_error("CGI script exit status %#x", sts)
+                exitcode = os.waitstatus_to_exitcode(sts)
+                if exitcode:
+                    self.log_error(f"CGI script exit code {exitcode}")
                 return
             # Child
             try:
diff --git a/Misc/NEWS.d/next/Library/2020-04-02-01-13-28.bpo-40094.AeZ34K.rst b/Misc/NEWS.d/next/Library/2020-04-02-01-13-28.bpo-40094.AeZ34K.rst
new file mode 100644
index 0000000000000..ba13d3cdf4a8d
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-04-02-01-13-28.bpo-40094.AeZ34K.rst
@@ -0,0 +1,3 @@
+CGIHTTPRequestHandler of http.server now logs the CGI script exit code,
+rather than the CGI script exit status of os.waitpid(). For example, if the
+script is killed by signal 11, it now logs: "CGI script exit code -11."



More information about the Python-checkins mailing list