[Patches] [ python-Patches-944928 ] Bugfix for dircheck() in Objects/fileobject.c

SourceForge.net noreply at sourceforge.net
Thu Apr 29 18:20:13 EDT 2004


Patches item #944928, was opened at 2004-04-30 00:20
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=944928&group_id=5470

Category: Core (C code)
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Ulrich Berning (uberning)
Assigned to: Nobody/Anonymous (nobody)
Summary: Bugfix for dircheck() in Objects/fileobject.c

Initial Comment:
When the sys module is initialized in _PySys_Init(), it
creates file objects for stdin, stdout and stderr with
PyFile_FromFile() which calls fill_file_fields() to
initialize the file object. At the end of
initialization dircheck() is called, to ensure that the
file is not a directory. If the underlaying file
descriptors for stdin, stdout, stderr (0, 1, 2) are
closed by the parent process, dircheck() fails at least
on AIX. I don't know exactly why this fails but the
following expression in dircheck() 

if (fstat(fileno(f->f_fp), &buf) == 0 &&
S_ISDIR(buf.st_mode))

evaluates to True for stdin which results in setting an
exception and returning NULL to _PySys_Init().

The applied patch changes dircheck() to return without
further checks if the file object is for stdin, stdout
or stderr.

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

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



More information about the Patches mailing list