[PATCH 5/9] Add compat.mmap.close to set _bup_closed and always inititalize it

0 views
Skip to first unread message

Rob Browning

unread,
Jan 16, 2022, 3:05:52 PM1/16/22
to bup-...@googlegroups.com
Add a compat.mmap.close method that properly maintains the _bup_closed
value, and make sure it always exists.

Signed-off-by: Rob Browning <r...@defaultvalue.org>
Tested-by: Rob Browning <r...@defaultvalue.org>
---
lib/bup/compat.py | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/bup/compat.py b/lib/bup/compat.py
index dfeb51ae..9def12a9 100644
--- a/lib/bup/compat.py
+++ b/lib/bup/compat.py
@@ -231,16 +231,19 @@ else: # Python 2

class mmap(py_mmap.mmap):
def __init__(self, *args, **kwargs):
- self._bup_closed = False
+ self._bup_closed = True
# Silence deprecation warnings. mmap's current parent is
# object, which accepts no params and as of at least 2.7
# warns about them.
if py_mmap.mmap.__init__ is not object.__init__:
super(mmap, self).__init__(self, *args, **kwargs)
+ self._bup_closed = False
+ def close(self):
+ self._bup_closed = True
+ super(mmap, self).close()
def __enter__(self):
return self
def __exit__(self, type, value, traceback):
- self._bup_closed = True
with pending_raise(value, rethrow=False):
self.close()
def __del__(self):
--
2.30.2

Reply all
Reply to author
Forward
0 new messages