From 7731644df4a263cff8e4e22bb544de30bceb2dbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Tue, 14 May 2024 16:29:27 +0200 Subject: [PATCH] Python 3.13 compatibility patches - Fixes: rhbz#2259516 --- 4356.patch | 40 ++++++++++++++++++++++++++++++++++++++++ 4357.patch | 30 ++++++++++++++++++++++++++++++ python-setuptools.spec | 4 ++++ 3 files changed, 74 insertions(+) create mode 100644 4356.patch create mode 100644 4357.patch diff --git a/4356.patch b/4356.patch new file mode 100644 index 0000000..3f980e3 --- /dev/null +++ b/4356.patch @@ -0,0 +1,40 @@ +From d53bf1509f40c8e84feb62ac13e91b76074a063a Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= +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 diff --git a/4357.patch b/4357.patch new file mode 100644 index 0000000..7222d3d --- /dev/null +++ b/4357.patch @@ -0,0 +1,30 @@ +From c6266e423fa26aafa01f1df71de7c6613273155e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= +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/" diff --git a/python-setuptools.spec b/python-setuptools.spec index 40e4e25..43dafa0 100644 --- a/python-setuptools.spec +++ b/python-setuptools.spec @@ -45,6 +45,10 @@ Patch: Remove-optional-or-unpackaged-test-deps.patch # adjust it, but only when $RPM_BUILD_ROOT is set 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 BuildRequires: python%{python3_pkgversion}-devel