When gpg.GzipWriteFile tries to write more bytes than the size parameter allows
it will quit and return False. (But for the signature file the return value is
not checked, in contrast to
the cases when the program writes the data itself. Those calls use the default size value.)
I guess the author meant to turn off the size check by choosing size=sys.maxsize
(instead of writing size=None and dealing properly with it.)
Here is what a supposed much simpler replacement function might look like, for one of these
functions (I haven't tested yet, and I don't understand the assert statement, which I
copied from the original).
Otherwise similar to GPGWriteFile
"""
file_out = open(filename, "wb")
# if gzipped wrap with GzipFile else plain file out
if gzipped:
outfile = gzip.GzipFile(None, "wb", 6, file_out)
else:
outfile = file_out
for new_block in block_iter: outfile.write(new_block.data)
assert not outfile.close() and not file_out.close()
I found the following passage in dup_temp.py:
if pr.compressed:
gpg. GzipWriteFile( src_iter, tgt.name, size=sys.maxsize)
gpg. GPGWriteFile( src_iter, tgt.name, globals. gpg_profile, size=sys.maxsize)
elif pr.encrypted:
sys.maxsize = 2*31-1 on 32-bit systems.
When gpg.GzipWriteFile tries to write more bytes than the size parameter allows
it will quit and return False. (But for the signature file the return value is
not checked, in contrast to
the cases when the program writes the data itself. Those calls use the default size value.)
I guess the author meant to turn off the size check by choosing size=sys.maxsize
(instead of writing size=None and dealing properly with it.)
Here is what a supposed much simpler replacement function might look like, for one of these
functions (I haven't tested yet, and I don't understand the assert statement, which I
copied from the original).
def GzipWriteFile_ without_ size_constraint (block_ iter, filename, gzipped=True):
"""
Write gzipped compressed file, without size constraint
Otherwise similar to GPGWriteFile
outfile. write(new_ block.data)
"""
file_out = open(filename, "wb")
# if gzipped wrap with GzipFile else plain file out
if gzipped:
outfile = gzip.GzipFile(None, "wb", 6, file_out)
else:
outfile = file_out
for new_block in block_iter:
assert not outfile.close() and not file_out.close()