-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy path0001-Fix-Python3.13-compatibility-regarding-urllib.parse-.patch
49 lines (41 loc) · 1.73 KB
/
0001-Fix-Python3.13-compatibility-regarding-urllib.parse-.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
From 187f1f6f3bf6e5f8da4f7029368ddd0967711ba9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?=
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