From ec49c586088ccb6a067855604c66ce6dde56a4b2 Mon Sep 17 00:00:00 2001 From: Vratislav Podzimek Date: Tue, 20 Sep 2016 15:30:36 +0200 Subject: [PATCH] New version - Prevent ignored exceptions in __del__ from happening (vpodzime) --- except_in_del.patch | 35 +++++++++++++++++++++++++++++++++++ libbytesize.spec | 8 +++++++- 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 except_in_del.patch diff --git a/except_in_del.patch b/except_in_del.patch new file mode 100644 index 0000000..2109fff --- /dev/null +++ b/except_in_del.patch @@ -0,0 +1,35 @@ +From 66851cc2630f7089d2de2bba054418cfd16563ad Mon Sep 17 00:00:00 2001 +From: Vratislav Podzimek +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 +--- + 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 + diff --git a/libbytesize.spec b/libbytesize.spec index 325c7b6..6d8a0c1 100644 --- a/libbytesize.spec +++ b/libbytesize.spec @@ -1,11 +1,13 @@ Name: libbytesize Version: 0.7 -Release: 2%{?dist} +Release: 3%{?dist} Summary: A library for working with sizes in bytes License: LGPLv2+ URL: https://github.com/rhinstaller/libbytesize Source0: https://github.com/rhinstaller/libbytesize/archive/%{name}-%{version}.tar.gz +Patch0: except_in_del.patch + %define realname bytesize BuildRequires: gmp-devel @@ -51,6 +53,7 @@ the library from Python 3 easier and more convenient. %prep %setup -q -n %{name}-%{version} +%patch0 -p1 %build %configure @@ -87,6 +90,9 @@ find %{buildroot} -type f -name "*.la" | xargs %{__rm} %{python3_sitearch}/bytesize/__pycache__/* %changelog +* Tue Sep 20 2016 Vratislav Podzimek - 0.7-3 +- Prevent ignored exceptions in __del__ from happening (vpodzime) + * Tue Jul 19 2016 Fedora Release Engineering - 0.7-2 - https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages