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

Guido van Rossum guido@digicool.com
Sat, 07 Apr 2001 13:43:45 -0500


> There's talk on the PythonMac-SIG to create an import hook that would
> read modules with either \r, \n or \r\n newlines and convert them to
> the local convention before feeding them to the rest of the import
> machinery. The reason this has become interesting is the mixed
> unixness/macness of MacOSX, where such an import hook could be used to
> share a Python tree between MacPython and bsd-Python. They would only
> need a different site.py (probably), living somehwere near the head of
> sys.path, that would be in local end of line convention and enable the
> hook.
> 
> However, it seem that such a module would have a much more general
> scope, for instance if you're accessing samba partitions from windows,
> or other foreign file systems, etc.
> 
> Does this sound like a good idea? And (even better:-) has anyone done
> this already? Would it be of enough interest to include it in the
> core Lib?

I know that it's too late for 2.1, but for 2.2, I think we can do
better: like Java, the import mechanism should accept all three line
ending conventions on all platforms!  It would also be nice if opening
a file in text mode did this transformation, but alas, that would
probably require more work on the file object than I care for.  But
import should be doable!

--Guido van Rossum (home page: http://www.python.org/~guido/)