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

noreply@sourceforge.net noreply@sourceforge.net
Wed, 19 Jun 2002 08:26:21 -0700


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

Category: Python Library
Group: Platform-specific
Status: Open
>Resolution: Accepted
Priority: 5
Submitted By: Tony Lownds (tonylownds)
>Assigned to: Jack Jansen (jackjansen)
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-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: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=570678&group_id=5470