Message356232
This seems to be the difference between Universal Newlines or not. In Python 2, you have to set it explicitly with a U in the open mode:
$ python2.7 -c 'import sys; print("Linecount=", sum(1 for x in open(sys.argv[1], "Ur")))' line_break_err.txt
('Linecount=', 18)
In Python 3, Universal Newlines is the default for text files, but you can control it with the ``newline`` parameter:
$ python3.5 -c 'import sys; print("Linecount=", sum(1 for x in open(sys.argv[1], newline="\n")))' line_break_err.txt
Linecount= 9
$ python3.5 -c 'import sys; print("Linecount=", sum(1 for x in open(sys.argv[1], newline="\r")))' line_break_err.txt
Linecount= 15
I think this explains the difference you are seeing. Do you agree? |
|
Date |
User |
Action |
Args |
2019-11-08 09:04:49 | steven.daprano | set | recipients:
+ steven.daprano, vstinner, ezio.melotti, serhiy.storchaka, thammegowda |
2019-11-08 09:04:49 | steven.daprano | set | messageid: <1573203889.87.0.675640434983.issue38740@roundup.psfhosted.org> |
2019-11-08 09:04:49 | steven.daprano | link | issue38740 messages |
2019-11-08 09:04:49 | steven.daprano | create | |
|