Group :: System/Libraries
RPM: libbytesize
Main Changelog Spec Patches Sources Download Gear Bugs and FR Repocop
Patch: except_in_del.patch
Download
Download
From 66851cc2630f7089d2de2bba054418cfd16563ad Mon Sep 17 00:00:00 2001
From: Vratislav Podzimek <vpodzime@redhat.com>
Date: Thu, 15 Sep 2016 10:56:36 +0200
Subject: [PATCH] Prevent ignored exceptions in __del__ from happening
For some reason we cannot call the functions from the loaded libbytesize C
library in some cases when __del__ is called. Let's just prevent the ignored
exceptions from happening.
Resolves: gh#19
Signed-off-by: Vratislav Podzimek <vpodzime@redhat.com>
---
src/python/bytesize.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/python/bytesize.py b/src/python/bytesize.py
index ec4b279..b68c5c4 100644
--- a/src/python/bytesize.py
+++ b/src/python/bytesize.py
@@ -97,7 +97,11 @@ class SizeStruct(ctypes.Structure):
return c_bytesize.bs_size_new_from_size(sz).contents
def __del__(self):
- c_bytesize.bs_size_free(self)
+ # XXX: For some reason c_bytesize may be None here (probably when python
+ # cleans up after itself) and loading it again doesn't work at that
+ # stage. Let's just prevent ignored exceptions from happening.
+ if c_bytesize:
+ c_bytesize.bs_size_free(self)
def get_bytes(self):
sgn = ctypes.c_int(0)
--
2.7.4