Fix build with Python 3.12

Patch submitted upstream: https://github.com/ClusterLabs/pcs/pull/713
This commit is contained in:
Yaakov Selkowitz 2023-07-10 12:51:55 -04:00
parent 11e6bb08f8
commit 2d244b8d72
2 changed files with 42 additions and 0 deletions

View File

@ -0,0 +1,39 @@
From c878e1d06d834f0beb5579158ea5b98c42965058 Mon Sep 17 00:00:00 2001
From: Yaakov Selkowitz <yselkowi@redhat.com>
Date: Mon, 10 Jul 2023 12:56:41 -0400
Subject: [PATCH] Fix DatatransferObjectTest for Python 3.12
This fixes a test error when run with Python 3.12:
```
Traceback (most recent call last):
File "pcs_test/tier0/common/interface/test_dto.py", line 41, in test_has_all_subclasses_are_dataclasses
_import_all(pcs.__path__)
File "pcs_test/tier0/common/interface/test_dto.py", line 31, in _import_all
loader.find_module(module_name).load_module(module_name)
^^^^^^^^^^^^^^^^^^
AttributeError: 'FileFinder' object has no attribute 'find_module'
```
Instead, use the spec-based APIs introduced in 3.4:
https://docs.python.org/3.12/library/importlib.html#importlib.machinery.FileFinder
https://docs.python.org/3.12/library/importlib.html#importlib.machinery.ModuleSpec
---
pcs_test/tier0/common/interface/test_dto.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pcs_test/tier0/common/interface/test_dto.py b/pcs_test/tier0/common/interface/test_dto.py
index 4c3dcb8b..977f35c9 100644
--- a/pcs_test/tier0/common/interface/test_dto.py
+++ b/pcs_test/tier0/common/interface/test_dto.py
@@ -28,7 +28,7 @@ def _import_all(_path):
if module_name.startswith("_pcs.snmp."):
continue
del is_pkg
- loader.find_module(module_name).load_module(module_name)
+ loader.find_spec(module_name).loader.load_module(module_name)
def _all_subclasses(cls):
--
2.41.0

View File

@ -48,6 +48,9 @@ Source101: https://github.com/ClusterLabs/pcs-web-ui/releases/download/%{ui_comm
# pcs patches: <= 200
# Patch0: name.patch
# https://github.com/ClusterLabs/pcs/pull/713
Patch0: 0001-Fix-DatatransferObjectTest-for-Python-3.12.patch
# ui patches: >200
# Patch201: name-web-ui.patch