summaryrefslogtreecommitdiffstats
path: root/Lib/py_compile.py
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2000-09-15 06:57:26 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2000-09-15 06:57:26 (GMT)
commitff1ce0f44f0c732fdffd24facb14e8a763a2fbf3 (patch)
tree20d82b7aa9cb0fcea08fcd435a7841e794677526 /Lib/py_compile.py
parentd2a5ad25d5f6734c919bd40ee26c3e11b98d6bc3 (diff)
downloadcpython-ff1ce0f44f0c732fdffd24facb14e8a763a2fbf3.zip
cpython-ff1ce0f44f0c732fdffd24facb14e8a763a2fbf3.tar.gz
cpython-ff1ce0f44f0c732fdffd24facb14e8a763a2fbf3.tar.bz2
Support \r in source files. Closes bug #101425.
Diffstat (limited to 'Lib/py_compile.py')
-rw-r--r--Lib/py_compile.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/py_compile.py b/Lib/py_compile.py
index c54d61b..b453109 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'