New submission from Matthew Boehm <boehm.matt...@gmail.com>: A file opened with codecs.open() splits on a form feed character (\x0c) while a file opened with open() does not.
>>> with open("formfeed.txt", "w") as f: ... f.write("line \fone\nline two\n") ... >>> with open("formfeed.txt", "r") as f: ... s = f.read() ... >>> s 'line \x0cone\nline two\n' >>> print s line one line two >>> import codecs >>> with open("formfeed.txt", "rb") as f: ... lines = f.readlines() ... >>> lines ['line \x0cone\n', 'line two\n'] >>> with codecs.open("formfeed.txt", "r", encoding="ascii") as f: ... lines2 = f.readlines() ... >>> lines2 [u'line \x0c', u'one\n', u'line two\n'] >>> Note that lines contains two items while lines2 has 3. Issue 7643 has a good discussion on newlines in python, but I did not see this discrepancy mentioned. ---------- components: Interpreter Core messages: 143182 nosy: Matthew.Boehm priority: normal severity: normal status: open title: open() and codecs.open() treat form-feed differently type: behavior versions: Python 2.7 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue12855> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com