[PYTHONMAC-SIG] UNIX files

Jack Jansen Jack.Jansen@cwi.nl
Thu, 10 Oct 1996 12:58:04 +0200


> > Hmm, Jack, what would be required to make Python interpret Unix line
> > endings, or at least recognize them and display a warning?
> 
> I'm not Jack, but I think there's only one or two places where modules
> are opened.  I wonder if we could open the file in binary mode and if
> we detect a CR in the first 512 bytes, reopen it in text mode...  The
> same hack should work for Windows!  On Unix, don't do this at all.

I was originally thinking about a solution in this vein, but I think that it 
is better to give an error. The problem with such an "accept everything" 
approach is that it will cause confusion in another place: when you open a 
unix textfile in your python program.

My suggestion would be to make \r be illegal to the parser. There is currently 
code in tokenizer.c that explicitly turns \r into \n, if this were disabled 
(and a decent error message was given, such as "SyntaxError, \r in line 
(non-native text file?)" this problem would easily be catched.
--
Jack Jansen             | ++++ stop the execution of Mumia Abu-Jamal ++++
Jack.Jansen@cwi.nl      | ++++ if you agree copy these lines to your sig ++++
http://www.cwi.nl/~jack | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm 



=================
PYTHONMAC-SIG  - SIG on Python for the Apple Macintosh

send messages to: pythonmac-sig@python.org
administrivia to: pythonmac-sig-request@python.org
=================