New version

- Prevent ignored exceptions in __del__ from happening (vpodzime)
This commit is contained in:
Vratislav Podzimek 2016-09-20 15:30:36 +02:00
parent 1f0d90661e
commit ec49c58608
2 changed files with 42 additions and 1 deletions

35
except_in_del.patch Normal file
View File

@ -0,0 +1,35 @@
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

View File

@ -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 <vpodzime@redhat.com> - 0.7-3
- Prevent ignored exceptions in __del__ from happening (vpodzime)
* Tue Jul 19 2016 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.7-2
- https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages