← Back to team overview

dulwich-users team mailing list archive

Re: [PATCH 3/6] pack.FilePackIndex: close mmap object

 

On Mon, Dec 20, 2010 at 11:00 PM, Jelmer Vernooij <jelmer@xxxxxxxxx> wrote:
> On Mon, 2010-12-20 at 22:53 +0800, Tay Ray Chuan wrote:
>> _load_file_contents may return a mmap object, so self._contents could be
>> mmap-ed. Close it if so.
>>
>> Note: we use hasattr() instead of isinstance() for pre-Python 2.6
>> compatibility (mmap became a class in Python 2.6).
> Please use getattr() rather than hasattr() as the latter eats
> exceptions.

According to the docs, hasattr() wraps around getattr() and "eats"
exceptions raised by the latter, returning False if an exception is
raised, so it should still be fine.

-- 
Cheers,
Ray Chuan



Follow ups

References