Jeffrey Kintscher <websur...@surf2c.net> added the comment:
The bz2 library and the bzip2 utility generate identical files. For example: >>> import bz2 >>> with bz2.open('bz2test.txt.bz2', mode='wb') as f: ... f.write(b'foobar') ... 6 generates this file: $ hexdump bz2test.txt.bz2 0000000 42 5a 68 39 31 41 59 26 53 59 52 c0 3d c1 00 00 0000010 01 01 80 31 00 90 00 20 00 21 83 41 9a 09 88 1c 0000020 5d c9 14 e1 42 41 4b 00 f7 04 000002a and $ echo -n 'foobar' | bzip2 -c > bzip2test.txt.bz2 generates this file: $ hexdump bzip2test.txt.bz2 0000000 42 5a 68 39 31 41 59 26 53 59 52 c0 3d c1 00 00 0000010 01 01 80 31 00 90 00 20 00 21 83 41 9a 09 88 1c 0000020 5d c9 14 e1 42 41 4b 00 f7 04 000002a The StreamFooter is there, it is just difficult to see because it isn't byte-aligned. It starts at byte 0x20 bit 6. If you take 0x5dc914e14241 and shift it right two bits, you get the StreamFooter FooterMagic value: 0x177245385090. It is followed by a 32-bit CRC and two zero-bits of padding to byte-align the end of the file. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue37005> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com