Eryk Sun <eryk...@gmail.com> added the comment:

3.9 can drop support for console pseudohandles in set_inheritable in 
Python/fileutils.c and Popen._filter_handle_list in Lib/subprocess.py. 

Also, _Py_write_impl in Python/fileutils.c can remove the 32767 byte limit for 
console files (and other character devices such as NUL, since it 
over-generalizes via isatty). The same applies to 
_io__WindowsConsoleIO_write_impl in Modules/_io/winconsoleio.c.

---
Discussion

In Windows 8+, the console uses "\\Device\\ConDrv" with kernel file objects. 
The console host process opens a file object for the ConDrv device itself in 
order to handle IOCTLs from clients. A console client process opens virtual 
files on ConDrv such as Connect (for generic functions such as GetConsoleCP), 
Input (default StandardInput), Output (default StandardOutput, StandardError), 
Console (//./CON), CurrentIn (//./CONIN$), and CurrentOut (//./CONOUT$). 
There's no practical limit on the size of reads and writes via these files.

Prior to Windows 8, console API requests are instead sent over an LPC port. 
Large messages that don't fit in a LPC packet are passed in a 64 KiB window of 
shared memory that's overlayed by a heap. This is the heap referred to by 
claims in the console API docs such as "[i]f the total size of the specified 
number of characters exceeds the available heap, the function fails with 
ERROR_NOT_ENOUGH_MEMORY".

With the LPC implementation, file handles for the console input buffer and 
screen buffer(s) are not real handles for kernel File objects. Rather, the 
console host process maintains a private table of pseudohandles for console 
buffers. These console pseudohandles are tagged for routing in the Windows API 
by setting the lower 2 bits. They're also verified in functions such as 
GetFileType via the undocumented function VerifyConsoleIoHandle. These 
pseudohandles have to be identified in Python because they're not supported by 
SetHandleInformation or the PROC_THREAD_ATTRIBUTE_HANDLE_LIST of CreateProcess, 
both of which require real kernel handles.

----------

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

Reply via email to