Dear group, I am trying to use the built-in lzma module to decompress a .lzma file, but it failed with the following errors:
_lzma.LZMAError: Corrupt input data
The .lzma file was compressed using the public-domain C library written by Igor Pavlov, see
before compression, the binary buffer has a length of 1966104 bytes, after compression, the file, mat.lzma
(can be downloaded from this link) has a length of 1536957 bytes.
when running file mat.lzma
, it prints
mat.lzma: LZMA compressed data, non-streamed, size 1966104
I was able to decompress this file using either the C library mentioned above, or using the below NodeJS/JavaScript script (with either lzma-purejs
or lzma
npm modules)
const fs = require('fs')
const lzma = require('lzma-purejs')
async function main() {
var data=lzma.decompressFile(fs.readFileSync('mat.lzma'));
console.log(data.length)
}
main().then(() => console.log('Done'))
the above script corrected decoded the buffer:
$ node testlzma.js
1966104
Done
however, using the below python script, I got an error
import lzma
filename='mat.lzma'
buf=lzma.open(filename, format=lzma.FORMAT_ALONE).read();
print(len(buf))
error message:
$ python3 testlzma.py
Traceback (most recent call last):
File "testlzma.py", line 4, in <module>
buf=lzma.open(filename, format=lzma.FORMAT_ALONE).read();
File "/usr/lib/python3.6/lzma.py", line 200, in read
return self._buffer.read(size)
File "/usr/lib/python3.6/_compression.py", line 103, in read
data = self._decompressor.decompress(rawblock, size)
_lzma.LZMAError: Corrupt input data
Because Igor Pavlov’s C library implements the original lzma algorithm, so I believe the FORMAT_ALONE flag was used correctly.
can someone take a look at this and let me know whether I used lzma module correctly or my file has some issues?
thanks