From: Martin v. Löwis Date: Fri, 15 Sep 2000 06:57:26 +0000 (+0000) Subject: Support \r in source files. Closes bug #101425. X-Git-Tag: v2.0b2~304 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ff1ce0f44f0c732fdffd24facb14e8a763a2fbf3;p=thirdparty%2FPython%2Fcpython.git Support \r in source files. Closes bug #101425. --- diff --git a/Lib/py_compile.py b/Lib/py_compile.py index c54d61b5f510..b4531096d719 100644 --- a/Lib/py_compile.py +++ b/Lib/py_compile.py @@ -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'