]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
python-common: fix valid_addr on python 3.11 52678/head
authorJohn Mulligan <jmulligan@redhat.com>
Thu, 27 Jul 2023 18:17:36 +0000 (14:17 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Thu, 27 Jul 2023 18:17:36 +0000 (14:17 -0400)
commitef72af7d720f8811368f25cb6f613ccaf5dcd55d
tree3f8c4982b336246db108976fe0a555b44fdde8e5
parent86b36a132dfee795ee579842ed1b5fa7b3a1eea7
python-common: fix valid_addr on python 3.11

The behavior on python 3.11 regarding IPv4 addresses in bracket has
changed:
```
$ python3.8 -c 'from urllib.parse import urlparse; urlparse("http://[192.168.0.1]")'

[john@edfu ~]$ python3.11 -c 'from urllib.parse import urlparse; urlparse("http://[192.168.0.1]")'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib64/python3.11/urllib/parse.py", line 395, in urlparse
    splitresult = urlsplit(url, scheme, allow_fragments)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/urllib/parse.py", line 500, in urlsplit
    _check_bracketed_host(bracketed_host)
  File "/usr/lib64/python3.11/urllib/parse.py", line 448, in
_check_bracketed_host
    raise ValueError(f"An IPv4 address cannot be in brackets")
ValueError: An IPv4 address cannot be in brackets
```

This breaks the test in test_valid_addr that asserts that function
valid_addr returns the string "IPv4 address wrapped in brackets is
invalid".
Move the step that checks for brackets and dots above the urllib
check so that the function continues returning the expected string.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/python-common/ceph/deployment/utils.py