From e7f24b7a3960f059837789fa4a5a836cbd27dd43 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 | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 changelog/66898.fixed.md diff --git a/changelog/66898.fixed.md b/changelog/66898.fixed.md new file mode 100644 index 000000000000..2549d5e00ed1 --- /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 478d8e911c2b..2c881ea2ef07 100644 --- a/salt/utils/url.py +++ b/salt/utils/url.py @@ -46,8 +46,7 @@ def create(path, saltenv=None): path = salt.utils.data.decode(path) query = f"saltenv={saltenv}" if saltenv else "" - url = salt.utils.data.decode(urlunparse(("file", "", path, "", query, ""))) - return "salt://{}".format(url[len("file:///") :]) + return f'salt://{salt.utils.data.decode(urlunparse(("", "", path, "", query, "")))}' def is_escaped(url):