Opening a file with tempfile.TemporaryFile using "wt+" mode, then reading content back, will cause reading to stop (without any exception) when encountering byte '0x1a' (aka. Ctrl+Z) on Windows even tough UTF-16 encoding is used. When using built-in open with the same parameters (plus a file name of course) everything works as expected. On Linux this issue does not exists.
File descriptors wrapped by the new IO module should be opened in binary mode. The attached patch changes TemporaryFile and NamedTemporaryFile to always call os.open() in binary mode; the mode is really used by the io.open() function. mkstemp() returns a raw file descriptor and was not changed.