python: Don't call __del__ from __exit__ method.
* lang/python/src/core.py (Context, Data): Don't call __del__ from __exit__ method, as the object may be still in use. * lang/python/tests/t-idiomatic.py: Fix the test. -- GnuPG-bug-id: 6060 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
parent
180899c7c3
commit
f8d99bb9e4
@ -1190,7 +1190,7 @@ class Context(GpgmeWrapper):
|
|||||||
return self
|
return self
|
||||||
|
|
||||||
def __exit__(self, type, value, tb):
|
def __exit__(self, type, value, tb):
|
||||||
self.__del__()
|
return False
|
||||||
|
|
||||||
def op_keylist_all(self, *args, **kwargs):
|
def op_keylist_all(self, *args, **kwargs):
|
||||||
self.op_keylist_start(*args, **kwargs)
|
self.op_keylist_start(*args, **kwargs)
|
||||||
@ -1528,7 +1528,7 @@ class Data(GpgmeWrapper):
|
|||||||
return self
|
return self
|
||||||
|
|
||||||
def __exit__(self, type, value, tb):
|
def __exit__(self, type, value, tb):
|
||||||
self.__del__()
|
return False
|
||||||
|
|
||||||
def _free_datacbs(self):
|
def _free_datacbs(self):
|
||||||
self._data_cbs = None
|
self._data_cbs = None
|
||||||
|
@ -35,6 +35,9 @@ with gpg.Context() as c, gpg.Data() as d:
|
|||||||
d.write(b"Halloechen")
|
d.write(b"Halloechen")
|
||||||
leak_c = c
|
leak_c = c
|
||||||
leak_d = d
|
leak_d = d
|
||||||
|
|
||||||
|
leak_c.__del__()
|
||||||
|
leak_d.__del__()
|
||||||
assert leak_c.wrapped is None
|
assert leak_c.wrapped is None
|
||||||
assert leak_d.wrapped is None
|
assert leak_d.wrapped is None
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user