Problem flushing stderr in embedded python
lashkariNO at SPAMworldviz.com
Wed Nov 10 21:00:09 CET 2004
Here's the code for PySys_GetObject. It's getting the object from the sys
dictionary, so it should be the correct object.
PyThreadState *tstate = PyThreadState_Get();
PyObject *sd = tstate->interp->sysdict;
if (sd == NULL)
return PyDict_GetItemString(sd, name);
I've tried calling fflush on stderr, but that doesn't work either.
I've encountered another weird problem also. If my python code causes an
error and I don't flush stderr, then I get a runtime error when my app
exits. It also prints out:
Exception exceptions.NameError: "global name 'y' is not defined" in 'garbage
Fatal Python error: unexpected exception during garbage collection.
Does this give anybody a clue as to what's happening?
"Donn Cave" <donn at drizzle.com> wrote in message
news:1100065836.697971 at yasure...
> Quoth "Farshid Lashkari" <lashkariNO at SPAMworldviz.com>:
> | I don't understand it from a C perspective either. I poked around the
> | 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
> | running the string "sys.stderr.flush()" is different than directly
> | 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.,
> 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 u.washington.edu
More information about the Python-list