Skip to content

Commit

Permalink
Remove usage of deprecated sre_constants module
Browse files Browse the repository at this point in the history
Remove usage of undocumented `sre_constants`
module deprecated in `python3.11` and use `re` module instead.

As dicsussed in python/cpython#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
  • Loading branch information
SRv6d committed Feb 13, 2023
1 parent 3876f3f commit 8588a4c
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions openstack/cloud/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from decorator import decorator
import jmespath
import netifaces
import sre_constants

from openstack import _log
from openstack.cloud import exc
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8588a4c

Please sign in to comment.