diff options
author | NIIBE Yutaka <[email protected]> | 2022-08-09 00:36:04 +0000 |
---|---|---|
committer | NIIBE Yutaka <[email protected]> | 2022-08-09 00:57:28 +0000 |
commit | f8d99bb9e4a7f6229c19c4fbd951ccad6fa97bde (patch) | |
tree | 1019c906b7d6f85a3b659210fad60ac3c36f4207 | |
parent | python: Don't access gpgme with wrapped=None. (diff) | |
download | gpgme-f8d99bb9e4a7f6229c19c4fbd951ccad6fa97bde.tar.gz gpgme-f8d99bb9e4a7f6229c19c4fbd951ccad6fa97bde.zip |
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 <[email protected]>
-rw-r--r-- | lang/python/src/core.py | 4 | ||||
-rwxr-xr-x | lang/python/tests/t-idiomatic.py | 3 |
2 files changed, 5 insertions, 2 deletions
diff --git a/lang/python/src/core.py b/lang/python/src/core.py index 81f961d9..c7b312b8 100644 --- a/lang/python/src/core.py +++ b/lang/python/src/core.py @@ -1190,7 +1190,7 @@ class Context(GpgmeWrapper): return self def __exit__(self, type, value, tb): - self.__del__() + return False def op_keylist_all(self, *args, **kwargs): self.op_keylist_start(*args, **kwargs) @@ -1528,7 +1528,7 @@ class Data(GpgmeWrapper): return self def __exit__(self, type, value, tb): - self.__del__() + return False def _free_datacbs(self): self._data_cbs = None diff --git a/lang/python/tests/t-idiomatic.py b/lang/python/tests/t-idiomatic.py index bc05e6c6..faa41906 100755 --- a/lang/python/tests/t-idiomatic.py +++ b/lang/python/tests/t-idiomatic.py @@ -35,6 +35,9 @@ with gpg.Context() as c, gpg.Data() as d: d.write(b"Halloechen") leak_c = c leak_d = d + +leak_c.__del__() +leak_d.__del__() assert leak_c.wrapped is None assert leak_d.wrapped is None |