New submission from Jake Lever <jake.le...@gmail.com>:

The attached code is designed to output compressed data to a gzip file. It 
creates two GzipFile objects, but only one is really used. It seems that it 
doesn't clean up and close the file properly.

In Py2, the attached code will fail. The output file (debug.txt.gz) will be 
corrupt. However if the self.unused line is commented out, it works and the 
file is not corrupted.

In Py3, a sys.exit call at the end is required to see the same behaviour.


As example output, when the sys.exit is include in Py3, the output is below and 
the file is corrupt.
Compressor.__init__
UnusedClass.write
UnusedClass.write
UnusedClass.write
UnusedClass.write
UnusedClass.write
UnusedClass.write
Compressor.compressToFile

And when the sys.exit is commented out, the console output is below and the 
file is not corrupt.

Compressor.__init__
UnusedClass.write
UnusedClass.write
UnusedClass.write
UnusedClass.write
UnusedClass.write
UnusedClass.write
Compressor.compressToFile
UnusedClass.write
UnusedClass.write
UnusedClass.write

----------
files: gzipBug.py
messages: 303662
nosy: Jake Lever
priority: normal
severity: normal
status: open
title: GZip library doesn't properly close files
type: behavior
versions: Python 2.7, Python 3.6
Added file: https://bugs.python.org/file47189/gzipBug.py

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue31686>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to