From adad4494c38cbc56d5bc6da8c247f36fca4531f2 Mon Sep 17 00:00:00 2001 From: Goffi Date: Wed, 8 Sep 2021 11:14:47 +0200 Subject: [PATCH] tools (common/uri): fix uri parsing for Python 3.9+ --- sat/tools/common/uri.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sat/tools/common/uri.py b/sat/tools/common/uri.py index ffbdcbcc..5ff54c1e 100644 --- a/sat/tools/common/uri.py +++ b/sat/tools/common/uri.py @@ -19,6 +19,7 @@ """ XMPP uri parsing tools """ +import sys import urllib.parse import urllib.request, urllib.parse, urllib.error @@ -53,7 +54,13 @@ def parseXMPPUri(uri): 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")