Support \r in source files. Closes bug #101425.

This commit is contained in:
Martin v. Löwis 2000-09-15 06:57:26 +00:00
parent d2a5ad25d5
commit ff1ce0f44f
1 changed files with 5 additions and 0 deletions

View File

@ -48,6 +48,11 @@ def compile(file, cfile=None, dfile=None):
except AttributeError:
timestamp = long(os.stat(file)[8])
codestring = f.read()
# If parsing from a string, line breaks are \n (see parsetok.c:tok_nextc)
# Replace will return original string if pattern is not found, so
# we don't need to check whether it is found first.
codestring = codestring.replace("\r\n","\n")
codestring = codestring.replace("\r","\n")
f.close()
if codestring and codestring[-1] != '\n':
codestring = codestring + '\n'