[Python-Dev] py_compile and CR in source files

Greg Ward gward@mems-exchange.org
Fri, 26 May 2000 10:30:15 -0400

Just made an unpleasant discovery: if a Python source file has CR-LF
line-endings, you can import it just fine under Unix.  But attempting to
'py_compile.compile()' it fails with a SyntaxError at the first

Arrghh!  This means that Distutils will either have to check/convert
line-endings at build-time (hey, finally, a good excuse for the
"build_py" command), or implicitly compile modules by importing them
(instead of using 'py_compile.compile()').

Perhaps I should "build" modules by line-at-a-time copying -- currently
it copies them in 16k chunks, which would make it hard to fix line
endings.  Hmmm.