From ef8079eb2739198ff1335499eeb78c93f09c650d Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 9 Oct 2025 15:45:03 +0530 Subject: [PATCH] Clear python error when using read_from_disk_cache_simple --- kitty/disk-cache.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kitty/disk-cache.h b/kitty/disk-cache.h index a4e8aaeb8..de48556ae 100644 --- a/kitty/disk-cache.h +++ b/kitty/disk-cache.h @@ -28,5 +28,9 @@ static inline void* disk_cache_malloc_allocator(void *x, size_t sz) { static inline bool read_from_disk_cache_simple(PyObject *self_, const void *key, size_t key_sz, void **data, size_t *data_sz, bool store_in_ram) { *data = read_from_disk_cache(self_, key, key_sz, disk_cache_malloc_allocator, data_sz, store_in_ram); - return PyErr_Occurred() == NULL; + if (PyErr_Occurred()) { + PyErr_Clear(); + return false; + } + return *data != NULL; }