Peter Creath <pjcreath+pyt...@gmail.com> added the comment:

A point of clarification on the original report: Georg is completely right when 
he points out that this is only an issue when passing in a file object.  If 
passed a filename, wave.py both opens and closes the file explicitly, and the 
dangling reference isn't important, as Antoine observes.

However, a retained reference in the file-object case is still a leak.

Georg writes: "Of course we could set _data_chunk to None, but I'm unsure what 
behavior change you would expect from that."

It allows garbage collection to close the file object if there are no more 
references to it.  It seems reasonable for a client of wave.py to assume that 
close() will release all references to the object, and indeed the code seems to 
support that assumption -- it sets _file to None.

If releasing references were truly of no importance, then I would argue that 
the line setting _file to None should be removed.  It serves no purpose after 
wave.py has explicitly closed the file (if it opened it) other than to release 
a reference to the file object.

Therefore, I suggest that _data_chunk should also be set to None in order to 
release the reference completely, thereby allowing the file object to be 
garbage collected.

----------

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

Reply via email to