Avoid deprecated importlib.abc.TraversableResources
This fixes python-ansible-compat's FTBFS with python3.12, as its test suite enforces -Werror.
This commit is contained in:
parent
bb45d530b8
commit
b700681263
@ -14,7 +14,7 @@ Name: ansible-core
|
|||||||
Summary: A radically simple IT automation system
|
Summary: A radically simple IT automation system
|
||||||
Version: 2.15.0
|
Version: 2.15.0
|
||||||
%global uversion %{version_no_tilde %{quote:%nil}}
|
%global uversion %{version_no_tilde %{quote:%nil}}
|
||||||
Release: 4%{?dist}
|
Release: 5%{?dist}
|
||||||
# The main license is GPLv3+. Many of the files in lib/ansible/module_utils
|
# The main license is GPLv3+. Many of the files in lib/ansible/module_utils
|
||||||
# are BSD licensed. There are various files scattered throughout the codebase
|
# are BSD licensed. There are various files scattered throughout the codebase
|
||||||
# containing code under different licenses.
|
# containing code under different licenses.
|
||||||
@ -44,6 +44,8 @@ Patch6001: https://github.com/ansible/ansible/commit/fd341265d001d4e6545ffb2b7d1
|
|||||||
Patch6002: https://github.com/ansible/ansible/commit/0df794e5a4fe4597ee65b0d492fbf0d0989d5ca0.patch#/urls-remove-deprecated-client-key-calls.patch
|
Patch6002: https://github.com/ansible/ansible/commit/0df794e5a4fe4597ee65b0d492fbf0d0989d5ca0.patch#/urls-remove-deprecated-client-key-calls.patch
|
||||||
# replace deprecated ast.value.s with ast.value.value (#80968)
|
# replace deprecated ast.value.s with ast.value.value (#80968)
|
||||||
Patch6003: https://github.com/ansible/ansible/commit/742d47fa15a5418f98abf9aaf07edf466e871c81.patch#/replace-deprecated-ast.value.s.patch
|
Patch6003: https://github.com/ansible/ansible/commit/742d47fa15a5418f98abf9aaf07edf466e871c81.patch#/replace-deprecated-ast.value.s.patch
|
||||||
|
# Avoid deprecated importlib.abc.TraversableResources (#81082)
|
||||||
|
Patch6004: https://github.com/ansible/ansible/pull/81082.patch#/avoid-importlib-resources-abc-deprecation.patch
|
||||||
|
|
||||||
Url: https://ansible.com
|
Url: https://ansible.com
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
@ -285,6 +287,9 @@ install -Dpm 0644 licenses/* -t %{buildroot}%{_pkglicensedir}
|
|||||||
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Sat Jun 17 2023 Maxwell G <maxwell@gtmx.me> - 2.15.0-5
|
||||||
|
- Add patch to avoid importlib.abc.TraversableResources DeprecationWarning
|
||||||
|
|
||||||
* Fri Jun 16 2023 Python Maint <python-maint@redhat.com> - 2.15.0-4
|
* Fri Jun 16 2023 Python Maint <python-maint@redhat.com> - 2.15.0-4
|
||||||
- Rebuilt for Python 3.12
|
- Rebuilt for Python 3.12
|
||||||
|
|
||||||
|
47
avoid-importlib-resources-abc-deprecation.patch
Normal file
47
avoid-importlib-resources-abc-deprecation.patch
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
From 2d84891781d6afb26fa5e3df1140602fa0fd7830 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Maxwell G <maxwell@gtmx.me>
|
||||||
|
Date: Sat, 17 Jun 2023 17:35:41 +0000
|
||||||
|
Subject: [PATCH] Avoid usage of deprecated importlib.abc.TraversableResources
|
||||||
|
|
||||||
|
This fixes ansible-compat test failures with Python 3.12.
|
||||||
|
---
|
||||||
|
.../fragments/81082-deprecated-importlib-abc.yml | 5 +++++
|
||||||
|
.../utils/collection_loader/_collection_finder.py | 12 +++++++++++-
|
||||||
|
2 files changed, 16 insertions(+), 1 deletion(-)
|
||||||
|
create mode 100644 changelogs/fragments/81082-deprecated-importlib-abc.yml
|
||||||
|
|
||||||
|
diff --git a/changelogs/fragments/81082-deprecated-importlib-abc.yml b/changelogs/fragments/81082-deprecated-importlib-abc.yml
|
||||||
|
new file mode 100644
|
||||||
|
index 00000000000000..6dfd90a16bed66
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/changelogs/fragments/81082-deprecated-importlib-abc.yml
|
||||||
|
@@ -0,0 +1,5 @@
|
||||||
|
+---
|
||||||
|
+minor_changes:
|
||||||
|
+ - Use ``importlib.resources.abc.TraversableResources`` instead of deprecated
|
||||||
|
+ ``importlib.abc.TraversableResources`` where available
|
||||||
|
+ (https:/github.com/ansible/ansible/pull/81082).
|
||||||
|
diff --git a/lib/ansible/utils/collection_loader/_collection_finder.py b/lib/ansible/utils/collection_loader/_collection_finder.py
|
||||||
|
index fc6744ffdef64e..edac8fa6f225b2 100644
|
||||||
|
--- a/lib/ansible/utils/collection_loader/_collection_finder.py
|
||||||
|
+++ b/lib/ansible/utils/collection_loader/_collection_finder.py
|
||||||
|
@@ -40,8 +40,18 @@ def import_module(name): # type: ignore[misc]
|
||||||
|
reload_module = reload # type: ignore[name-defined] # pylint:disable=undefined-variable
|
||||||
|
|
||||||
|
try:
|
||||||
|
- from importlib.abc import TraversableResources
|
||||||
|
+ try:
|
||||||
|
+ # Available on Python >= 3.11
|
||||||
|
+ # We ignore the import error that will trigger when running mypy with
|
||||||
|
+ # older Python versions.
|
||||||
|
+ from importlib.resources.abc import TraversableResources # type: ignore[import]
|
||||||
|
+ except ImportError:
|
||||||
|
+ # Used with Python 3.9 and 3.10 only
|
||||||
|
+ # This member is still available as an alias up until Python 3.14 but
|
||||||
|
+ # is deprecated as of Python 3.12.
|
||||||
|
+ from importlib.abc import TraversableResources
|
||||||
|
except ImportError:
|
||||||
|
+ # Python < 3.9
|
||||||
|
TraversableResources = object # type: ignore[assignment,misc]
|
||||||
|
|
||||||
|
try:
|
Loading…
Reference in New Issue
Block a user