Author erik.bray
Recipients erik.bray
Date 2016-10-17.10:58:11
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1476701892.4.0.598393414511.issue28459@psf.upfronthosting.co.za>
In-reply-to
Content
Since the patch to #24881 was merged the _pyio module has been non-importable on Cygwin, due to an attempt to import from the msvcrt module.

However, the msvcrt module is not built on Cygwin (Cygwin does not use MSVCRT).  Cygwin's libc does, however, have _setmode.

The problem this is trying to solve is to call _setmode (https://msdn.microsoft.com/en-us/library/tw4k6df8.aspx) on file descriptors to ensure that they are O_BINARY instead of O_TEXT (a distinction that needs to made on Windows).

Fortunately, on Cygwin, it is fairly rare that a file descriptor will have mode O_TEXT, but it it is possible.  See https://cygwin.com/faq/faq.html#faq.programming.msvcrt-and-cygwin

This could be tricky to solve though.  Removing setmode() call entirely works for me as far as the test suite is concerned.  But it leaves _pyio slightly incongruous with the C implementation in this one small aspect, and it *is* a bug.

I would propose for Python 3.7 adding an os.setmode() function.  On Windows this could be simply an alias for msvcrt.setmode() (or vice-versa).  But because setmode() is available also in Cygwin (and technically some other platforms too, though none that are currently supported by Python) it would be a good candidate for inclusion in the os module I think (for those platforms that have it).
History
Date User Action Args
2016-10-17 10:58:12erik.braysetrecipients: + erik.bray
2016-10-17 10:58:12erik.braysetmessageid: <1476701892.4.0.598393414511.issue28459@psf.upfronthosting.co.za>
2016-10-17 10:58:12erik.braylinkissue28459 messages
2016-10-17 10:58:11erik.braycreate