[Pythonmac-SIG] Using a unix Python with a MacPython Lib tree

Jack Jansen jack@oratrix.nl
Wed, 04 Apr 2001 11:40:13 +0200


> One idea that would have simplified my problem (and anyone else who is
> embedding Python) and can fix the LF/CR return problem is to replace the
> stdio FILE * and stdio function calls. On all platforms without the LF/CR
> problem you could just do something like:
> 
>     #define PYIO_FILE       FILE
>     #define PYIO_fprintf    fprintf
>     #define PYIO_fgets      fgets

Unfortunately, this is blasphemy. The BDFL has announced that Python will be 
stdio-based. There is a pretty good reason for this: most similar language 
implementations (Perl, Tcl/Tk) at some point were lured into doing their own 
stdio-lookalike I/O system, but these were quickly extended with all sorts of 
nifty new features, thereby making an I/O system port a prerequisite before 
the languages in question could be ported to a new platform. Sticking with 
stdio is probably one of the main factors that makes Python ports easy, and 
therefore one of the main factors that contribute to Python being available on 
far more platforms (from IBM mainframes to Palm organisers) than similar 
languages.

So, I think we're stuck with modifying stdio itself. But, the good news is 
that with many current stdio implementations this shouldn't be too hard, 
provided you have access to the source. Stdio will often have a per-FILE 
struct of function pointers to do lowlevel operations that you can plug into.
--
Jack Jansen             | ++++ stop the execution of Mumia Abu-Jamal ++++
Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++
www.oratrix.nl/~jack    | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm