X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fbup%2Findex.py;fp=lib%2Fbup%2Findex.py;h=e7214d1daca24c79a7598b6822d10c9f050a4541;hb=ce50c0b3537327b2ec0bfda031cc4ec99e2ca870;hp=d0df52a4bbe158b661e5df44bda8b1b22b1c6d1f;hpb=5f3b0e5826049499148086b91d8139b8679e1a01;p=bup.git diff --git a/lib/bup/index.py b/lib/bup/index.py index d0df52a..e7214d1 100644 --- a/lib/bup/index.py +++ b/lib/bup/index.py @@ -439,8 +439,12 @@ class Reader: self.m[st.st_size - FOOTLEN : st.st_size])[0] - def __del__(self): - self.close() + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + with pending_raise(value, rethrow=False): + self.close() def __len__(self): return int(self.count)