eryksun added the comment:

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

----------

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

Reply via email to