classification
Title: WindowsConsoleIO fileno() passes wrong flags to _open_osfhandle
Type: behavior Stage: resolved
Components: IO, Library (Lib), Windows Versions: Python 3.7, Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: steve.dower Nosy List: eryksun, paul.moore, python-dev, steve.dower, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2016-09-15 03:26 by eryksun, last changed 2017-03-31 16:36 by dstufft. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 552 closed dstufft, 2017-03-31 16:36
Messages (3)
msg276509 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2016-09-15 03:26
WindowsConsoleIO fileno() gets a file descriptor on demand by calling _open_osfhandle. As a low I/O function this expects _open flags, but currently the code is passing 'rb' (int 0x7262) and 'wb' (int 0x7762). It should use _O_RDONLY | _O_BINARY and _O_WRONLY | _O_BINARY. 

Actually, _open_osfhandle isn't actually opening the file, so it only cares about a few flags. Specifically, in lowio\osfinfo.cpp I see that it looks for _O_APPEND, _O_TEXT, and _O_NOINHERIT. So in this case passing 0 for the flags would also be ok.
msg276840 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2016-09-17 20:32
I'll pass the "correct" flags, since the docs don't specify that they aren't used, which means one day they might become relevant.
msg276846 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-09-17 20:51
New changeset d0bab9fda568 by Steve Dower in branch '3.6':
Issue #28161: Opening CON for write access fails
https://hg.python.org/cpython/rev/d0bab9fda568

New changeset 187a114b9ef4 by Steve Dower in branch 'default':
Issue #28161: Opening CON for write access fails
https://hg.python.org/cpython/rev/187a114b9ef4
History
Date User Action Args
2017-03-31 16:36:12dstufftsetpull_requests: + pull_request877
2016-09-17 20:53:13steve.dowersetstatus: open -> closed
resolution: fixed
stage: needs patch -> resolved
2016-09-17 20:51:45python-devsetnosy: + python-dev
messages: + msg276846
2016-09-17 20:32:05steve.dowersetassignee: steve.dower
messages: + msg276840
2016-09-15 03:26:21eryksuncreate