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: pythonrun.c does not check std streams the same as fileio.c
Type: Stage: resolved
Components: IO, Windows Versions: Python 3.5
process
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, pitrou, steve.dower, stutzbach, tim.golden, vstinner, zach.ware
Priority: normal Keywords: patch

Created on 2014-07-10 22:02 by steve.dower, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
pythonrun_fstat.diff steve.dower, 2014-07-10 22:02 review
Messages (3)
msg222706 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2014-07-10 22:02
In pythonrun.c, the is_valid_fd() function checks whether fileno(std*) are valid before attempting to create IO objects for them. However, the class created also checks using fstat().

In pythonw.exe built with VS 2013 (or 14, maybe 2012), the fstat() check fails while the earlier one succeeds. This prevents pythonw from starting.

The attached patch adds the fstat() check to pythonrun.c so that if the streams are not usable they will simply not be used. I believe this was the original intent, but at some point the invalid streams gained valid file numbers.

(I have no strong opinion about applying this to 3.4, except that it will help out people who rebuild/embed that version of Python with a newer compiler. Thoughts?)
msg222750 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014-07-11 14:38
See also issues:

- issue #17797: Visual C++ 11.0 reports fileno(stdin) == 0 for non-console program
- issue #18804: I proposed a similar change for other reasons.
msg222806 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2014-07-11 22:24
This is definitely the same as #17797, so I'll close this as a dup. Over on that issue, it's confirmed as fixed in VC14 (and it is - I've checked).
History
Date User Action Args
2022-04-11 14:58:05adminsetgithub: 66152
2014-07-11 22:26:13zach.waresetstage: resolved
2014-07-11 22:24:34steve.dowersetstatus: open -> closed
resolution: duplicate
messages: + msg222806
2014-07-11 14:38:27vstinnersetnosy: + vstinner
messages: + msg222750
2014-07-10 22:02:05steve.dowercreate