From 8588a4c7afb7969fc62a03e058236149b54ddedc Mon Sep 17 00:00:00 2001 From: Marvin Vogt Date: Mon, 13 Feb 2023 10:28:05 +0100 Subject: [PATCH] Remove usage of deprecated `sre_constants` module Remove usage of undocumented `sre_constants` module deprecated in `python3.11` and use `re` module instead. As dicsussed in https://github.com/python/cpython/issues/91308, `sre_constants` is undocumented and it's usage was deprecated starting with `python3.11`, where it causes a deprecation warning. https://docs.python.org/3/whatsnew/3.11.html#modules Importing `sre_constants` for exception handling of invalid regular expressions in not necessary, as the same exception class is exposed through the `re` module. Change-Id: Ifd9cccf504a5493683152178ebef9183f30b7f4c --- openstack/cloud/_utils.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openstack/cloud/_utils.py b/openstack/cloud/_utils.py index 259d08bb0..50bbb6d3e 100644 --- a/openstack/cloud/_utils.py +++ b/openstack/cloud/_utils.py @@ -23,7 +23,6 @@ from decorator import decorator import jmespath import netifaces -import sre_constants from openstack import _log from openstack.cloud import exc @@ -93,7 +92,7 @@ def _filter_list(data, name_or_id, filters): bad_pattern = False try: fn_reg = re.compile(fnmatch.translate(name_or_id)) - except sre_constants.error: + except re.error: # If the fnmatch re doesn't compile, then we don't care, # but log it in case the user DID pass a pattern but did # it poorly and wants to know what went wrong with their