diff --git a/CHANGELOG.md b/CHANGELOG.md index 930e0634b..55093c05c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ - Assume all Thunderbird users prefer encryption #3774 - refactor peerstate handling to ensure no duplicate peerstates #3776 - Fetch messages in order of their INTERNALDATE (fixes reactions for Gmail f.e.) #3789 +- python: do not pass NULL to ffi.gc if the context can't be created #3818 ## 1.102.0 diff --git a/python/src/deltachat/account.py b/python/src/deltachat/account.py index d02f37348..302fa395f 100644 --- a/python/src/deltachat/account.py +++ b/python/src/deltachat/account.py @@ -82,12 +82,13 @@ class Account(object): if hasattr(db_path, "encode"): db_path = db_path.encode("utf8") - self._dc_context = ffi.gc( - lib.dc_context_new_closed(db_path) if closed else lib.dc_context_new(ffi.NULL, db_path, ffi.NULL), - lib.dc_context_unref, - ) + ptr = lib.dc_context_new_closed(db_path) if closed else lib.dc_context_new(ffi.NULL, db_path, ffi.NULL) if self._dc_context == ffi.NULL: raise ValueError("Could not dc_context_new: {} {}".format(os_name, db_path)) + self._dc_context = ffi.gc( + ptr, + lib.dc_context_unref, + ) self._shutdown_event = Event() self._event_thread = EventThread(self)