]> arthur.barton.de Git - bup.git/commitdiff
git/packwriter: open(..) prohibited in __del__
authorBas Stottelaar <basstottelaar@gmail.com>
Fri, 7 Aug 2020 11:04:19 +0000 (13:04 +0200)
committerRob Browning <rlb@defaultvalue.org>
Mon, 22 Nov 2021 16:34:38 +0000 (10:34 -0600)
When an exception occurs, __del__ is invoked by the interpreter, to
perform cleanup. It seems that since Python 3.4, the behaviour has
changed, and also prohibits invocations of open(..) (source:
https://stackoverflow.com/a/29737870). Instead, contextmanager API
should be used (source: https://stackoverflow.com/a/26544629), which
seems to be in place already.

This should fix exception messages such as 'NameError: name 'open'
is not defined'.

Signed-off-by: Bas Stottelaar <basstottelaar@gmail.com>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/git.py

index fbcf481cf90967e8ecac4e6c5745ea2b12f42b80..4c1a95c52a985e5eaee1bb36ef4ca61651559c78 100644 (file)
@@ -750,9 +750,6 @@ class PackWriter:
         self.max_pack_objects = max_pack_objects if max_pack_objects \
                                 else max(1, self.max_pack_size // 5000)
 
-    def __del__(self):
-        self.close()
-
     def __enter__(self):
         return self