This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: CGIHTTPServer fix
Type: Stage:
Components: Library (Lib) Versions: Python 2.3
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: gvanrossum Nosy List: gvanrossum, loewis, rhettinger
Priority: normal Keywords: patch

Created on 2003-08-28 16:34 by gvanrossum, last changed 2022-04-10 16:10 by admin. This issue is now closed.

File name Uploaded Description Edit
diff.txt gvanrossum, 2003-08-28 16:34 diff for
Messages (4)
msg44523 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2003-08-28 16:34
Here's a fix for the CGI server. The problem only
occurs on systems that support os.fork(). When you
invoke a CGI script with a query string and then
subsequent invoke it without a query string (or with an
empty query string), the second invocation gets passed
the query string of the first invocation. This is
because of the way os.environ is updated in the parent,
but when there is no query string, the old query string
doesn't get deleted. The solution is to update the
os.environ in the child.
msg44524 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2003-08-31 14:48
Logged In: YES 

The first part of the patch makes sense to me.
The second part updates os.environ which is shared between 
successive calls.  I would have expected something like:

   childenv = os.environ.copy()
    . . .
   os.execve(scriptfile, args, childenv)
msg44525 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2003-09-10 06:12
Logged In: YES 

I agree with rhettinger. The original patch assumes that the
platform has putenv/setenv, which it might not (if it
doesn't, then the os.environ.update is not reflected in the
C environment, and thus has no effect on os.execv).

Whether or not os.environ needs to be copied is debatable;
the copying has its cost, but avoiding the putenv calls
would save some of the costs.
msg44526 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2004-03-20 23:06
Logged In: YES 

I believe the fix I checked in for SF 777848 solves this in
a different way.

Can either of the reviewers see any problem with that solution?
Date User Action Args
2022-04-10 16:10:53adminsetgithub: 39142
2003-08-28 16:34:36gvanrossumcreate