This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eryksun
Recipients BreamoreBoy, eryksun, ezio.melotti, ionelmc, r.david.murray, vstinner
Date 2014-06-19.14:38:45
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1403188726.15.0.364099049917.issue21808@psf.upfronthosting.co.za>
In-reply-to
Content
> sys.stdout.write() doen't use WriteFile. Again, see the 
> issue #1602 if you are interested to improve the Unicode 
> support of the Windows console.

_write calls WriteFile because Python 3 sets standard I/O to binary mode. The source is distributed with Visual Studio, so here's the relevant excerpt from write.c:

        else {
                /* binary mode, no translation */
                if ( WriteFile( (HANDLE)_osfhnd(fh),
                                (LPVOID)buf,
                                cnt,
                               (LPDWORD)&written,
                                NULL) )
                {
                        dosretval = 0;
                        charcount = written;
                }
                else
                        dosretval = GetLastError();
        }

In a debugger you can trace that WriteFile detects the handle is a console buffer handle (the lower 2 tag bits are set on the handle), and redirects the call to WriteConsoleA, which makes an LPC interprocess call to the console server (e.g. csrss.exe or conhost.exe). The LPC call, and associated heap limit, is the reason you had to modify _io.FileIO.write to limit the buffer size to 32767 when writing to the Windows console. See issue 11395.
History
Date User Action Args
2014-06-19 14:38:46eryksunsetrecipients: + eryksun, vstinner, ezio.melotti, ionelmc, r.david.murray, BreamoreBoy
2014-06-19 14:38:46eryksunsetmessageid: <1403188726.15.0.364099049917.issue21808@psf.upfronthosting.co.za>
2014-06-19 14:38:46eryksunlinkissue21808 messages
2014-06-19 14:38:45eryksuncreate