]> arthur.barton.de Git - bup.git/commit
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)
commit20db61170c8a8fd4b452ec29f6a3133385c4fdad
treec1bb169ec4afb97efadfa8d10bbbb71dbffe49d3
parent53b57e5fcb1980d49c22d1fd53d992cee3b2797a
git/packwriter: open(..) prohibited in __del__

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