diff --git a/examples-event-test-Use-atexit-for-Python-3.patch b/examples-event-test-Use-atexit-for-Python-3.patch new file mode 100644 index 0000000000000000000000000000000000000000..2894fc244015214d2898f7848e287d847d486f1f --- /dev/null +++ b/examples-event-test-Use-atexit-for-Python-3.patch @@ -0,0 +1,55 @@ +From cb8cceb0d8498bf0e2595a0830ab253afc3d64c7 Mon Sep 17 00:00:00 2001 +From: Philipp Hahn +Date: Mon, 27 Apr 2020 14:57:04 +0200 +Subject: [PATCH 001/297] examples/event-test: Use atexit for Python 3 + +Assigning sys.exitfunc no longer works with Python 3. + +Use atexit.register() instead. + +Signed-off-by: Philipp Hahn +--- + examples/event-test.py | 8 +++----- + 1 file changed, 3 insertions(+), 5 deletions(-) + +diff --git a/examples/event-test.py b/examples/event-test.py +index 0bebf23..7a73da5 100755 +--- a/examples/event-test.py ++++ b/examples/event-test.py +@@ -6,6 +6,7 @@ + # Start off by implementing a general purpose event loop for anyone's use + ############################################################################## + ++import atexit + import sys + import getopt + import os +@@ -15,6 +16,7 @@ import errno + import time + import threading + ++ + # This example can use three different event loop impls. It defaults + # to a portable pure-python impl based on poll that is implemented + # in this file. +@@ -776,16 +778,12 @@ def main(): + vc = libvirt.openReadOnly(uri) + + # Close connection on exit (to test cleanup paths) +- old_exitfunc = getattr(sys, 'exitfunc', None) +- + def exit(): + print("Closing " + vc.getURI()) + if run: + vc.close() +- if (old_exitfunc): +- old_exitfunc() + +- sys.exitfunc = exit ++ atexit.register(exit) + + vc.registerCloseCallback(myConnectionCloseCallback, None) + +-- +2.38.1.windows.1 + diff --git a/libvirt-python.spec b/libvirt-python.spec index 1a3dd7d491a4eeea20e20478d076ef8fdf91a3fc..6047fff8a8f26982752da9ceefd071747a0d6d2b 100644 --- a/libvirt-python.spec +++ b/libvirt-python.spec @@ -3,7 +3,7 @@ Summary: The libvirt virtualization API python3 binding Name: libvirt-python Version: 6.2.0 -Release: 7 +Release: 8 Source0: http://libvirt.org/sources/python/%{name}-%{version}.tar.gz Patch0000: setup-use-pytest-instead-of-nose-to-run-the-test-sui.patch Patch0001: spec-use-pytest-instead-of-nose.patch @@ -15,6 +15,7 @@ Patch0006: Avoid-truncating-python-version-number-when-running-.patch Patch0007: Fix-the-invalid-operation-between-incompatible-types.patch Patch0008: Fix-string-formatting.patch Patch0009: Fix-BlockThreshold-Callback-argument-conversion-once.patch +Patch0010: examples-event-test-Use-atexit-for-Python-3.patch Url: http://libvirt.org License: LGPLv2+ BuildRequires: libvirt-devel == %{version} @@ -80,6 +81,9 @@ find examples -type f -exec chmod 0644 \{\} \; %{python3_sitearch}/*egg-info %changelog +* Mon Jul 17 2023 shechenglong - 6.2.0-8 +- examples: examples/event-test: Use atexit for Python 3 + * Thu May 11 2023 ChenYanpan - 6.2.0-7 - add BuildRequires python3-libvirt to fix build failure