Python 3.13 compatibility patches

- Fixes: rhbz#2259516
This commit is contained in:
Miro Hrončok 2024-05-14 16:29:27 +02:00
parent 6cfde0c365
commit 7731644df4
3 changed files with 74 additions and 0 deletions

40
4356.patch Normal file
View File

@ -0,0 +1,40 @@
From d53bf1509f40c8e84feb62ac13e91b76074a063a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
Date: Tue, 14 May 2024 16:19:02 +0200
Subject: [PATCH] Explicitly disallow resource paths starting with single
backslash
Previously, such paths were disallowed implicitly
as they were treated as Windows absolute paths.
Since Python 3.13, paths starting with a single backslash are not considered
Windows-absolute, so we treat them specially.
This change makes the existing doctest pass with Python 3.13.
Partially fixes https://github.com/pypa/setuptools/issues/4196
---
pkg_resources/__init__.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py
index 713d9bdfa3..faee7dec79 100644
--- a/pkg_resources/__init__.py
+++ b/pkg_resources/__init__.py
@@ -1604,6 +1604,7 @@ def _validate_resource_path(path):
os.path.pardir in path.split(posixpath.sep)
or posixpath.isabs(path)
or ntpath.isabs(path)
+ or path.startswith("\\")
)
if not invalid:
return
@@ -1611,7 +1612,7 @@ def _validate_resource_path(path):
msg = "Use of .. or absolute path in a resource path is not allowed."
# Aggressively disallow Windows absolute paths
- if ntpath.isabs(path) and not posixpath.isabs(path):
+ if (path.startswith("\\") or ntpath.isabs(path)) and not posixpath.isabs(path):
raise ValueError(msg)
# for compatibility, warn; in future

30
4357.patch Normal file
View File

@ -0,0 +1,30 @@
From c6266e423fa26aafa01f1df71de7c6613273155e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
Date: Tue, 14 May 2024 16:24:07 +0200
Subject: [PATCH] Make the validation test for entry-points work with Python
3.13+
The exception in importlib.metadata has changed.
See https://github.com/python/importlib_metadata/issues/488
This makes an existing test pass with Python 3.13.
Partially fixes https://github.com/pypa/setuptools/issues/4196
---
setuptools/_entry_points.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/setuptools/_entry_points.py b/setuptools/_entry_points.py
index 747a69067e..b244e78387 100644
--- a/setuptools/_entry_points.py
+++ b/setuptools/_entry_points.py
@@ -17,7 +17,8 @@ def ensure_valid(ep):
"""
try:
ep.extras
- except AttributeError as ex:
+ except (AttributeError, AssertionError) as ex:
+ # Why both? See https://github.com/python/importlib_metadata/issues/488
msg = (
f"Problems to parse {ep}.\nPlease ensure entry-point follows the spec: "
"https://packaging.python.org/en/latest/specifications/entry-points/"

View File

@ -45,6 +45,10 @@ Patch: Remove-optional-or-unpackaged-test-deps.patch
# adjust it, but only when $RPM_BUILD_ROOT is set # adjust it, but only when $RPM_BUILD_ROOT is set
Patch: Adjust-the-setup.py-install-deprecation-message.patch Patch: Adjust-the-setup.py-install-deprecation-message.patch
# Python 3.13 compatibility patches, merged upstream
Patch: https://github.com/pypa/setuptools/pull/4356.patch
Patch: https://github.com/pypa/setuptools/pull/4357.patch
BuildArch: noarch BuildArch: noarch
BuildRequires: python%{python3_pkgversion}-devel BuildRequires: python%{python3_pkgversion}-devel