This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author steven.daprano
Recipients ezio.melotti, serhiy.storchaka, steven.daprano, thammegowda, vstinner
Date 2019-11-08.09:04:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1573203889.87.0.675640434983.issue38740@roundup.psfhosted.org>
In-reply-to
Content
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?
History
Date User Action Args
2019-11-08 09:04:49steven.dapranosetrecipients: + steven.daprano, vstinner, ezio.melotti, serhiy.storchaka, thammegowda
2019-11-08 09:04:49steven.dapranosetmessageid: <1573203889.87.0.675640434983.issue38740@roundup.psfhosted.org>
2019-11-08 09:04:49steven.dapranolinkissue38740 messages
2019-11-08 09:04:49steven.dapranocreate