[issue18804] pythorun.c: is_valid_fd() should not duplicate the file descriptor

STINNER Victor report at bugs.python.org
Thu Aug 22 01:07:47 CEST 2013


New submission from STINNER Victor:

is_valid_fd() of Python/pythorun.c should use fstat() to check if a file descriptor is valid, instead of duplicating it using dup() (and then closing it).

If Windows needs a special check, it would be better to run checks on the handle of the file descriptor.

The function was added by the following changeset:

----------------------------
branch:      3.2
parent:      73773:661fb211f220
user:        Antoine Pitrou <solipsis at pitrou.net>
date:        Mon Nov 28 19:08:36 2011 +0100
files:       Lib/test/test_cmd_line.py Misc/NEWS Python/pythonrun.c
description:
Issue #7111: Python can now be run without a stdin, stdout or stderr stream.

It was already the case with Python 2.  However, the corresponding
sys module entries are now set to None (instead of an unusable file object).
----------------------------


See also issue #17797 "Visual C++ 11.0 reports fileno(stdin) == 0 for non-console program".

----------
messages: 195836
nosy: haypo, pitrou
priority: normal
severity: normal
status: open
title: pythorun.c: is_valid_fd() should not duplicate the file descriptor
versions: Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18804>
_______________________________________


More information about the Python-bugs-list mailing list