Changing interpreter's deafult output/error streams

Ira sheig222 at gmail.com
Mon Aug 1 14:08:56 CEST 2005


OK let me rephrase,

the standard error stream (and if I'm not mistaken also the one that
PyErr_Print() writes to) is the python object sys.stderr. Now say I'd go
ahead and write the following in python...

SomeNewStreamOrFileOrWhateverItIs = new stream
sys.stderr = SomeNewStreamOrFileOrWhateverItIs

I can go ahead and do the exact same thing from the C source code. All I
need to do is to figure out how to wrap a c-style FILE* with a PyObject, And
PySys_SetObjet("stderr", newstream);

I'm very new to python so that might be nonsense but it appeals to my
programmer's common sense. Can anyone tell me how to do this?


"Michael Hudson" <mwh at python.net> wrote in message
news:m24qaa95m3.fsf at 82-33-185-193.cable.ubr01.azte.blueyonder.co.uk...
> "Ira" <sheig222 at gmail.com> writes:
>
> > Using an embedded interpreter, how do I change it's default output
> > streams (specifically the one used by PyErr_Print() which I'm
> > guessing is the default error stream)?
>
> It looks as though it writes to stderr unconditionally.  But most of
> the reasons for ended up in PyErr_Print can be intercepted at a higher
> level (I think -- I mean sys.excepthook & co here).
>
> Cheers,
> mwh
>
> -- 
>   ARTHUR:  Yes.  It was on display in the bottom of a locked filing
>            cabinet stuck in a disused lavatory with a sign on the door
>            saying "Beware of the Leopard".
>                     -- The Hitch-Hikers Guide to the Galaxy, Episode 1
> -- 
> http://mail.python.org/mailman/listinfo/python-list
>






More information about the Python-list mailing list