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: Bugfix for dircheck() in Objects/fileobject.c
Type: Stage:
Components: Interpreter Core Versions: Python 2.3
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: georg.brandl, loewis, uberning
Priority: normal Keywords: patch

Created on 2004-04-29 22:20 by uberning, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
fileobject.patch uberning, 2004-04-29 22:20 Patch for Objects/fileobject.c
Messages (3)
msg45887 - (view) Author: Ulrich Berning (uberning) Date: 2004-04-29 22:20
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.
msg45888 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2004-08-18 13:42
Logged In: YES 
user_id=21627

This patch is not acceptable in this form. What you describe
seems to point to a clear bug in AIX, and, as other AIX
users have not reported that as a problem, appears to be
specific to your installation. Maybe there is a problem with
the compiler installation somehow?

If you want to investigate this further, please try to
reproduce the stat/ISDIR problem in a small stand-alone C
program. If that succeeds, please generate an
strace/ktrace/truss output for that binary.
msg45889 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2005-09-15 13:16
Logged In: YES 
user_id=1188172

Closing due to lack of response and improbability of validity.
History
Date User Action Args
2022-04-11 14:56:03adminsetgithub: 40201
2004-04-29 22:20:13uberningcreate