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 sjmachin
Recipients baloan, eric.araujo, sjmachin, skip.montanaro, zacktu
Date 2010-12-24.00:52:40
SpamBayes Score 1.1046719e-14
Marked as misclassified No
Message-id <1293151962.88.0.236494852663.issue7198@psf.upfronthosting.co.za>
In-reply-to
Content
Please re-open this. The binary/text mode problem still exists with Python 3.X on Windows. Quite simply, there is no option available to the caller to open the output file in binary mode, because the module is throwing str objects at the file. The module's idea of "taking control" in the default case appears to be to write \r\n which is then processed by the Windows runtime and becomes \r\r\n.

Python 3.1.3 (r313:86834, Nov 27 2010, 18:30:53) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import csv
>>> f = open('terminator31.csv', 'w')
>>> row = ['foo', None, 3.14159]
>>> writer = csv.writer(f)
>>> writer.writerow(row)
14
>>> writer.writerow(row)
14
>>> f.close()
>>> open('terminator31.csv', 'rb').read()
b'foo,,3.14159\r\r\nfoo,,3.14159\r\r\n'
>>>

And it's not just a row terminator problem; newlines embedded in fields are likewise expanded to \r\n by the Windows runtime.
History
Date User Action Args
2010-12-24 00:52:43sjmachinsetrecipients: + sjmachin, skip.montanaro, baloan, eric.araujo, zacktu
2010-12-24 00:52:42sjmachinsetmessageid: <1293151962.88.0.236494852663.issue7198@psf.upfronthosting.co.za>
2010-12-24 00:52:41sjmachinlinkissue7198 messages
2010-12-24 00:52:40sjmachincreate