Author serhiy.storchaka
Recipients gvanrossum, ned.deily, ronaldoussoren, serhiy.storchaka
Date 2017-02-15.12:21:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1487161265.61.0.450348509296.issue29566@psf.upfronthosting.co.za>
In-reply-to
Content
binhex.binhex() creates files with mixed line endings in Python 3. The header line '(This file must be converted with BinHex 4.0)' is separated from the data by LFs, but the data is split for lines by CRs.

>>> import binhex
>>> with open('inp', 'wb') as f: f.write(bytes(range(256)))
... 
256
>>> binhex.binhex('inp', 'outp')
>>> for line in open('outp', 'rb').read().splitlines(True): print(repr(line))
... 
b'(This file must be converted with BinHex 4.0)\r'
b'\r'
b':!fPZF!!rN!J!N!3"!*!&*VF!!3)$"!8\'"`J*#JX-$3i2%"%5%a39&KFB\'4SE("d\n'
b'H(b!K)L-N*5BR+#NU+b`Y,Lm`-6)c0$8f0cJj1MXm26ir3%&#3d4&4NG)58T,6%e\n'
b'16e"48P0899CA@&PD@eaGAPpJB@*MC\'9QCfKTDQYXE@j[F(&bFh4eGRGiHATlI(e\n'
b'qIi#"JS1%KBD(L)Q+Lib0MSq3!*\'5Nj59PTHBQCUER*fHRk#KSU1NTDDRU+QUUkb\n'
b'YVUq`XE+cY,@fYlLjZVZm[Ekr`-(#`m6&aXI)bFV,c-h1cp$4dY28eGEAf0RDfpc\n'
b'GhYrJiH,Mj1AQjqMTkZ[XlHl[m2(bmr6ep[IiqIVlr2hqrhj9!!!:\n'

In Python 2 the output file was file object usually opened in text mode. Newline characters were translated to platform-depending line endings: CRLF on Windows, LF on classic Mac OS. In Python 2 the output file is binary stream that doesn't do any newline translations.

The last related commit is 34a042d301d6ab88645046a6dfa6c38265ca4b39 with Guido's message "This is the last time I fix binhex.  If it breaks again it goes in the dustbin."
History
Date User Action Args
2017-02-15 12:21:05serhiy.storchakasetrecipients: + serhiy.storchaka, gvanrossum, ronaldoussoren, ned.deily
2017-02-15 12:21:05serhiy.storchakasetmessageid: <1487161265.61.0.450348509296.issue29566@psf.upfronthosting.co.za>
2017-02-15 12:21:05serhiy.storchakalinkissue29566 messages
2017-02-15 12:21:04serhiy.storchakacreate