Problem flushing stderr in embedded python

Donn Cave donn at
Wed Nov 10 06:50:38 CET 2004

Quoth "Farshid Lashkari" <lashkariNO at>:
| I don't understand it from a C perspective either. I poked around the source
| code for python and found where it is flushing the file. It is simply
| calling fflush on the FILE handle. Also, I'm somewhat bewildered as to why
| running the string "sys.stderr.flush()" is different than directly calling
| the flush method of the stderr object. Oh well, I guess some things are
| better left unknown.

It could be different if the stderr object - i.e., PySys_GetObject("stderr") -
is actually not sys.stderr.  I don't understand why, but am not familiar
with PySys_*, so I offer that as a hypothesis you might be able to test.
By the way, since as you observed it's only calling fflush(), I think you
could leave Python out of it altogether and do this with just

	Donn Cave, donn at

More information about the Python-list mailing list