[issue36304] When using bz2 and lzma in mode 'wt', the BOM is not written

2019-03-18 Thread STINNER Victor
Change by STINNER Victor : -- nosy: -vstinner ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.p

[issue36304] When using bz2 and lzma in mode 'wt', the BOM is not written

2019-03-18 Thread Gianluca
Gianluca added the comment: In case the file is not seekable, we could decide based on the file mode: - if mode='w', write the BOM - if mode='a', don't write the BOM Of course, mode "a" doesn't guarantee we are in the middle of the file, but it seems a consistent behavior not writing the BOM

[issue36304] When using bz2 and lzma in mode 'wt', the BOM is not written

2019-03-15 Thread Martin Panter
Martin Panter added the comment: I suspect this is caused by TextIOWrapper guessing if it is writing the start of a file versus in the middle, and being confused by “seekable” returning False. GzipFile implements some “seek” calls in write mode, but LZMAFile and BZ2File do not. Using this te

[issue36304] When using bz2 and lzma in mode 'wt', the BOM is not written

2019-03-15 Thread Terry J. Reedy
Change by Terry J. Reedy : -- nosy: +benjamin.peterson, ezio.melotti, lemburg, vstinner ___ Python tracker ___ ___ Python-bugs-list

[issue36304] When using bz2 and lzma in mode 'wt', the BOM is not written

2019-03-15 Thread Gianluca
Gianluca added the comment: As one can read in the stackoverflow answer, using _pyio.TextIOWrapper works as expected. So it looks like this is a bug of _io.TextIOWrapper. -- ___ Python tracker _

[issue36304] When using bz2 and lzma in mode 'wt', the BOM is not written

2019-03-15 Thread Gianluca
New submission from Gianluca : When bz2 and lzma files are used in writing text mode (wrapped in a TextIOWrapper), the BOM of encodings such as utf-16 and utf-32 is not written. The gzip package works as expected (it writes the BOM). The code that demonstrate this behavior (tested with Python