andyvand / pefile

Automatically exported from code.google.com/p/pefile
Other
0 stars 0 forks source link

mmap files left open on Python 2.5.x (with latest r112 trunk and r111 too) #32

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
PE() creates a mmap file.
The mmap is never closed on python 2.5.x because mmap.mmap is a factory 
function and not a class. The behavior changed in 2.6 and mmap.mmap is now a 
class.
The attached patch does two things:
- first it ensures with a finally that PE.close() is always called
- second it does systematically closing self.__data__ if and only if the mmap 
data where loaded from a file
In fact if I passed a data arg instead of a file, I would not want my data to 
be closed without me knowing it.
a bit hackish but it takes care of the various cases nicely imho.

Thanks for pefile :)

Original issue reported on code.google.com by pombreda...@gmail.com on 2 Aug 2011 at 1:16

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks for reporting this and for the patch!

Original comment by ero.carr...@gmail.com on 24 Aug 2011 at 10:20

GoogleCodeExporter commented 9 years ago
The patch needed some adjustments (it was breaking my tests) but I've committed 
it on revision 113

Original comment by ero.carr...@gmail.com on 24 Aug 2011 at 10:39

GoogleCodeExporter commented 9 years ago
Thank ++ . The patch was ugly and barely tested

Original comment by pombreda...@gmail.com on 27 Aug 2011 at 7:25