Author pjcreath
Recipients georg.brandl, ned.deily, pitrou, pjcreath
Date 2011-01-12.20:16:44
SpamBayes Score 7.61263e-12
Marked as misclassified No
Message-id <>
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, 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 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 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.
Date User Action Args
2011-01-12 20:16:59pjcreathsetrecipients: + pjcreath, georg.brandl, pitrou, ned.deily
2011-01-12 20:16:59pjcreathsetmessageid: <>
2011-01-12 20:16:44pjcreathlinkissue10855 messages
2011-01-12 20:16:44pjcreathcreate