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.

classification
Title: CGIHTTPServer flushes read-only file.
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: gvanrossum Nosy List: gvanrossum, jackjansen, kasplat, tonylownds
Priority: normal Keywords:

Created on 2002-06-18 16:59 by tonylownds, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
CGIHTTPServer.patch tonylownds, 2002-06-18 16:59 patch to Lib/CGIHTTPServer.py
Messages (5)
msg11252 - (view) Author: Tony Lownds (tonylownds) Date: 2002-06-18 16:59
On Mac OS X, flushing a file open only for reading
causing an IOError. That behavior matches what the
system's fflush man page describes:

ERRORS
     [EBADF]            Stream is not an open stream,
or, in the case of
                        fflush(), not a stream open for
writing.

CGIHTTPServer.py calls .flush on the read-only part of
it's socket before it forks and then quickly breaks.

The attached patch simply removes that line.
The bug is listed as Platform-specific because this
behavior does not appear under Linux (even though the
fflush man page on Linux lists the same EBADF error).

msg11253 - (view) Author: Jack Jansen (jackjansen) * (Python committer) Date: 2002-06-19 09:26
Logged In: YES 
user_id=45365

Apparently Guido is the one who put the self.rfile.flush() call in there, so he's probably also the person who knows whether it's a good idea to take it out again.
msg11254 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-06-19 15:26
Logged In: YES 
user_id=6380

I thought the C standard supports fflush() on a stream open
for reading as a way to clear the buffer and reposition the
file descriptor to its logical position. Maybe I'm mistaken;
maybe the MacOS X stdio library is not standard-conforming.
But I think it's fine to take that flush() out here, because
(1) it's a socket, and (2) it's unbuffered.
msg11255 - (view) Author: Kevin Altis (kasplat) Date: 2002-08-01 20:33
Logged In: YES 
user_id=228025

If this patch has been accepted and integrated into the 
sources in cvs, then this should issue should be closed out. If 
there is some reason it hasn't been rolled into the sources, 
what is the reason?

I'm just trying to chase down the issues with the CGI handling 
in the standard lib for Windows and OS X. Commenting out 
the flush line appears to allow CGIs to work. It appears that 
environment variables are not showing up in CGIs on the Mac 
OS X, but that should be a separate issue.

Thanks,

ka
msg11256 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-08-01 21:13
Logged In: YES 
user_id=6380

OK, checked in. Thanks for reminding me (it had fallen off
my plate :-).
History
Date User Action Args
2022-04-10 16:05:25adminsetgithub: 36767
2002-06-18 16:59:02tonylowndscreate