[Python-bugs-list] [ python-Bugs-570678 ] CGIHTTPServer flushes read-only file.

noreply@sourceforge.net noreply@sourceforge.net
Thu, 01 Aug 2002 14:13:31 -0700


Bugs item #570678, was opened at 2002-06-18 12:59
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=570678&group_id=5470

Category: Python Library
Group: Platform-specific
>Status: Closed
Resolution: Accepted
Priority: 5
Submitted By: Tony Lownds (tonylownds)
>Assigned to: Guido van Rossum (gvanrossum)
Summary: CGIHTTPServer flushes read-only file.

Initial Comment:
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).



----------------------------------------------------------------------

>Comment By: Guido van Rossum (gvanrossum)
Date: 2002-08-01 17:13

Message:
Logged In: YES 
user_id=6380

OK, checked in. Thanks for reminding me (it had fallen off
my plate :-).

----------------------------------------------------------------------

Comment By: Kevin Altis (kasplat)
Date: 2002-08-01 16:33

Message:
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

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2002-06-19 11:26

Message:
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.

----------------------------------------------------------------------

Comment By: Jack Jansen (jackjansen)
Date: 2002-06-19 05:26

Message:
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.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=570678&group_id=5470