Exploring terminfo

Grant Edwards grant.b.edwards at gmail.com
Fri Jan 15 13:33:04 EST 2021


On 2021-01-15, Grant Edwards <grant.b.edwards at gmail.com> wrote:

> I suspect that the problem is that putp is writing to the libc
> "stdout" FILE stream that's declaredin <stdio.h>. That stream
> layer/object has buffering that is invisible to Python. Python's
> sys.stdout.flush() is flushing the Python file object's output buffers
> to the standard output file descriptor(fd 2).

This problem probably didn't happen with older versions of python
where python's stdout file object was on top of the libc stdout FILE
stream, and calling sys.stdout.flush() flushed both layers of
buffering out to the file descriptor.

Starting in Python 3.<something>, python's stdio file objects are _not_
on top of the libc FILE streams: they're directly on top of the file
descriptor.

IOW, Python's stdout file object buffering and ncurses stdout FILE
buffering are independent of each other. They reside "beside" each
other, both writing to the file descriptor whenever they see fit with
no coordination between the two.

--
Grant



More information about the Python-list mailing list