Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport patch fixing Python 3.13 compat #7

Merged
merged 4 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ include:
project: QubesOS/qubes-continuous-integration
- file: /r4.3/gitlab-vm.yml
project: QubesOS/qubes-continuous-integration
- file: /r4.2/gitlab-base.yml
project: QubesOS/qubes-continuous-integration
- file: /r4.2/gitlab-host.yml
project: QubesOS/qubes-continuous-integration
12 changes: 12 additions & 0 deletions .qubesbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ vm-fc38:
rpm:
build:
- salt.spec
vm-fc39:
rpm:
build:
- salt.spec
vm-fc40:
rpm:
build:
- salt.spec
vm-fc41:
rpm:
build:
- salt.spec
vm-bookworm:
deb:
build:
Expand Down
10 changes: 7 additions & 3 deletions 0001-Drop-versioned-certifi-dependency.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Date: Thu, 15 Aug 2024 03:46:12 +0200
Subject: [PATCH] Drop versioned certifi dependency

Let it pick the version from the distribution.
Similarly for requests.
---
requirements/base.txt | 2 --
1 file changed, 2 deletions(-)
Expand All @@ -13,10 +14,13 @@ diff --git a/requirements/base.txt b/requirements/base.txt
index de9cbaab17..bce14bc510 100644
--- a/requirements/base.txt
+++ b/requirements/base.txt
@@ -7,8 +7,6 @@ PyYAML
@@ -7,10 +7,7 @@ PyYAML
msgpack>=1.0.0
PyYAML
MarkupSafe
requests<2.32.0 ; python_version < '3.10'
requests>=2.32.3 ; python_version >= '3.10'
-requests<2.32.0 ; python_version < '3.10'
-requests>=2.32.3 ; python_version >= '3.10'
+requests
-certifi==2023.07.22; python_version < '3.10'
-certifi>=2024.7.4; python_version >= '3.10'
distro>=1.0.1
Expand Down
49 changes: 49 additions & 0 deletions 0001-Fix-Python3.13-compatibility-regarding-urllib.parse-.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
From 187f1f6f3bf6e5f8da4f7029368ddd0967711ba9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?=
<marmarek@invisiblethingslab.com>
Date: Wed, 18 Sep 2024 04:54:24 +0200
Subject: [PATCH] Fix Python3.13 compatibility regarding urllib.parse module

Python 3.13 fixed handling relative paths in urllib.parse module.
Specifically, relative file URL is now constructed as file:path instead
of converting it to absolute file:///path. This breaks
salt.utils.url.create which expects file:/// specifically. The mismatch
results in for example changing salt://top.sls into salt://.sls and thus
not finding the top file.

Fix this by handling both prefixes.

Relevant python change: https://github.com/python/cpython/issues/85110
Fixes: #66898
---
changelog/66898.fixed.md | 1 +
salt/utils/url.py | 5 ++++-
2 files changed, 5 insertions(+), 1 deletion(-)
create mode 100644 changelog/66898.fixed.md

diff --git a/changelog/66898.fixed.md b/changelog/66898.fixed.md
new file mode 100644
index 0000000000..2549d5e00e
--- /dev/null
+++ b/changelog/66898.fixed.md
@@ -0,0 +1 @@
+Fixed Python 3.13 compatibility regarding urllib.parse module
diff --git a/salt/utils/url.py b/salt/utils/url.py
index 478d8e911c..6d7ea37e6d 100644
--- a/salt/utils/url.py
+++ b/salt/utils/url.py
@@ -47,7 +47,10 @@ def create(path, saltenv=None):

query = f"saltenv={saltenv}" if saltenv else ""
url = salt.utils.data.decode(urlunparse(("file", "", path, "", query, "")))
- return "salt://{}".format(url[len("file:///") :])
+ # urlunparse changed behavior in Python 3.13
+ if url.startswith("file:///"):
+ return "salt://{}".format(url[len("file:///") :])
+ return "salt://{}".format(url[len("file:") :])


def is_escaped(url):
--
2.46.0

1 change: 1 addition & 0 deletions salt.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Patch1: match_hostname.patch
Patch2: 0002-Hide-known-DeprecationWarning-related-to-PEP-594.patch
Patch3: 0001-Drop-versioned-certifi-dependency.patch
Patch4: 0001-Use-timezone-aware-datetime-objects-for-UTC-too.patch
Patch5: 0001-Fix-Python3.13-compatibility-regarding-urllib.parse-.patch
BuildArch: noarch

%ifarch %{ix86} x86_64
Expand Down