[New-bugs-announce] [issue21953] pythonrun.c does not check std streams the same as fileio.c

Steve Dower report at bugs.python.org
Fri Jul 11 00:02:05 CEST 2014

New submission from Steve Dower:

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?)

components: IO, Windows
files: pythonrun_fstat.diff
keywords: patch
messages: 222706
nosy: benjamin.peterson, pitrou, steve.dower, stutzbach, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: pythonrun.c does not check std streams the same as fileio.c
versions: Python 3.5
Added file: http://bugs.python.org/file35921/pythonrun_fstat.diff

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list