From bd8d21b3538ac17c81bb148462afb0e189e42824 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Fri, 13 Dec 2024 23:57:57 +0900 Subject: [PATCH] Drop compatibility code for Python 3.8 Python 3.8 support has been removed and now the minimum supported python version is 3.9. Change-Id: Ic1fa1921ef3c66f5fd32a4e6e23dc843bc877f42 --- oslo_utils/netutils.py | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/oslo_utils/netutils.py b/oslo_utils/netutils.py index 59a1fabd..8ee9c4b9 100644 --- a/oslo_utils/netutils.py +++ b/oslo_utils/netutils.py @@ -144,19 +144,10 @@ def get_noscope_ipv6(address): .. versionadded: 7.3.0: """ - # TODO(egarciar): Scope was added for IPv6Address on Python 3.9. Same for - # the removesuffix str method. Remove try/except when minimum required - # version for Python is 3.9 - try: - _ipv6 = ipaddress.IPv6Address(address) - if _ipv6.scope_id: - address = address.removesuffix('%' + _ipv6.scope_id) - return address - except (ipaddress.AddressValueError, AttributeError): - if is_valid_ipv6(address): - parts = address.rsplit("%", 1) - return parts[0] - raise + _ipv6 = ipaddress.IPv6Address(address) + if _ipv6.scope_id: + address = address.removesuffix('%' + _ipv6.scope_id) + return address def is_valid_cidr(address):