[Python-bugs-list] [ python-Bugs-505490 ] Improve I/O redirection to embedding app

noreply@sourceforge.net noreply@sourceforge.net
Fri, 18 Jan 2002 11:00:07 -0800


Bugs item #505490, was opened at 2002-01-18 11:00
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=505490&group_id=5470

Category: Extension Modules
Group: Feature Request
Status: Open
Resolution: None
Priority: 5
Submitted By: Stefan Franke (sfranke)
Assigned to: Nobody/Anonymous (nobody)
Summary: Improve I/O redirection to embedding app

Initial Comment:
When embedding Python into an existing application, you
usually do two things (among others):
1. Make Python use your own memory allocation
2. Redirect its I/O to the embedding app

While the former is very easy due to the excellent
pymem.h interface, the latter is quite painful, since
the interpreter uses stdin/out/err directly.

The common workaround I found on c.l.p is providing
your own file-like objects in an extension module and
assign them to sys.stdout/err within the interpreter.
This solution still has its problems (like getting
errors while import site.py)

I wish Python would encapsulate I/O in a similar way
than its malloc interface, and in some way I would
expect this from a language which is said to be 
designed for extending and embedding.

Unluckily I'm not able to this myself. I started my 
first embedding project a few days ago and still miss
the big picture about Python's C API.


----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=505490&group_id=5470