changeset 3642:cc3b453670a2

tools (common/uri): fix uri parsing for Python 3.9+
author Goffi <goffi@goffi.org>
date Wed, 08 Sep 2021 11:14:47 +0200
parents 0ffaa231138c
children 30196b9a2b4c
files sat/tools/common/uri.py
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/sat/tools/common/uri.py	Wed Sep 08 11:14:17 2021 +0200
+++ b/sat/tools/common/uri.py	Wed Sep 08 11:14:47 2021 +0200
@@ -19,6 +19,7 @@
 
 """ XMPP uri parsing tools """
 
+import sys
 import urllib.parse
 import urllib.request, urllib.parse, urllib.error
 
@@ -53,7 +54,13 @@
     if query_end == -1 or "=" in query_type:
         raise ValueError("no query type, invalid XMPP URI")
 
-    pairs = urllib.parse.parse_qs(uri_split.geturl())
+    if sys.version_info >= (3, 9):
+        # parse_qs behaviour has been modified in Python 3.9, ";" is not understood as a
+        # parameter separator anymore but the "separator" argument has been added to
+        # change it.
+        pairs = urllib.parse.parse_qs(uri_split.geturl(), separator=";")
+    else:
+        pairs = urllib.parse.parse_qs(uri_split.geturl())
     for k, v in list(pairs.items()):
         if len(v) != 1:
             raise NotImplementedError("multiple values not managed")