[Pythonmac-SIG] Re: [Python-Dev] Import hook to do end-of-line conversion?

Just van Rossum just@letterror.com
Mon, 9 Apr 2001 22:00:22 +0200


Proposal for 2.2, outline for a PEP?


1)
The Python file object needs to be modified so that in text mode it can
recognize all major line ending conventions (Unix, Win and Mac).

Reading data:
  - recognize \n, \r and \r\n as line ending, present as \n to Python
Writing data:
  - convert \n to the platform line endings (this is already the case)

This modification should be _optional_, because it may break code under unix
(insert Guido's explanation here), and because it may not support oddball
systems like OpenVMS.

It should be _on_ by default under:
- Windows
- MacPython Classic
- MacPython Carbon
- Unix Python under MacOS X / Darwin

It should probably be off by default on all other systems (I think a
compile-time switch is good enough). Maybe if we advertize the potential
sloppy-unix-code-breakage loud enough we can make the feature mandatory in a
later release, however I don't see a practical way of issuing warnings for the
situation.


2)
I assume there are quite a few places where Python uses raw C text files: these
places should be identified, we should figure out how much work it is to fix
these so they behave just like the Python file object as described above.



Who would like to team up with me to write a decent PEP and maybe an example
implementation?


Just