New submission from Erik Bray:

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

----------
components: IO
messages: 278802
nosy: erik.bray
priority: normal
severity: normal
status: open
title: _pyio module broken on Cygwin / setmode not usable
type: crash

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue28459>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to