I found something interesting.
>>> with codecs.open('hax', encoding='utf-8') as f: print(list(f))
...
['foo\r', 'bar\r', 'baz']
>>> with open('hax', 'rb') as f: print([l.decode('utf-8') for l in f])
...
['foo\rbar\rbaz']
>>> with open('hax', encoding='utf-8') as f: print(list(f))
...
['foo\n', 'bar\n', 'baz']
codecs.open, with an encoding specified, opens the file in binary mode. It then has some different logic: it doesn’t translate newlines (the way that “universal newline” mode does for files opened in text mode do now in 3.x); but it does recognize them (which is different from opening the file in binary mode “manually”, which can only recognize b'\n' as a “line ending”). It seems to use the string splitlines method for this.
So I think I got part of the first post wrong. Unless it’s changed since then ![]()