[Python-checkins] cpython: Close #12289: Fix "is executable?" test in the CGI server

victor.stinner python-checkins at python.org
Mon Jun 20 17:46:59 CEST 2011


http://hg.python.org/cpython/rev/ecef74419d55
changeset: 70908:ecef74419d55
user: Victor Stinner <victor.stinner at haypocalc.com>
date: Mon Jun 20 17:45:54 2011 +0200
summary:
 Close #12289: Fix "is executable?" test in the CGI server
Use os.access(path, os.X_OK) instead of (os.stat(path).st_mode & 0o111 != 0),
and ignore the test on Windows.
files:
 Lib/http/server.py | 8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)
diff --git a/Lib/http/server.py b/Lib/http/server.py
--- a/Lib/http/server.py
+++ b/Lib/http/server.py
@@ -897,11 +897,7 @@
 
 def executable(path):
 """Test for executable file."""
- try:
- st = os.stat(path)
- except os.error:
- return False
- return st.st_mode & 0o111 != 0
+ return os.access(path, os.X_OK)
 
 
 class CGIHTTPRequestHandler(SimpleHTTPRequestHandler):
@@ -1015,7 +1011,7 @@
 scriptname)
 return
 ispy = self.is_python(scriptname)
- if not ispy:
+ if self.have_fork or not ispy:
 if not self.is_executable(scriptfile):
 self.send_error(403, "CGI script is not executable (%r)" %
 scriptname)
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /