(original) (raw)
diff --git a/Lib/http/server.py b/Lib/http/server.py --- a/Lib/http/server.py +++ b/Lib/http/server.py @@ -895,15 +895,6 @@ def nobody_uid(): return nobody -def executable(path): - """Test for executable file.""" - try: - st = os.stat(path) - except os.error: - return False - return st.st_mode & 0o111 != 0 - - class CGIHTTPRequestHandler(SimpleHTTPRequestHandler): """Complete HTTP server with GET, HEAD and POST commands. @@ -966,7 +957,7 @@ class CGIHTTPRequestHandler(SimpleHTTPRe def is_executable(self, path): """Test whether argument path is an executable file.""" - return executable(path) + return os.access(path, os.X_OK) def is_python(self, path): """Test whether argument path is a Python script.""" @@ -1015,7 +1006,7 @@ class CGIHTTPRequestHandler(SimpleHTTPRe 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)