diff --git a/beets/autotag/hooks.py b/beets/autotag/hooks.py index 3615a9333..1c62a54c5 100644 --- a/beets/autotag/hooks.py +++ b/beets/autotag/hooks.py @@ -31,6 +31,12 @@ import six log = logging.getLogger('beets') +# The name of the type for patterns in re changed in Python 3.7. +try: + Pattern = re._pattern_type +except AttributeError: + Pattern = re.Pattern + # Classes used to represent candidate options. @@ -433,7 +439,7 @@ class Distance(object): be a compiled regular expression, in which case it will be matched against `value2`. """ - if isinstance(value1, re._pattern_type): + if isinstance(value1, Pattern): return bool(value1.match(value2)) return value1 == value2 diff --git a/docs/changelog.rst b/docs/changelog.rst index be6de2904..d487f31f5 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -19,6 +19,8 @@ New features: Fixes: +* Fix compatibility Python 3.7 and its change to a name in the ``re`` module. + :bug:`2978` * R128 normalization tags are now properly deleted from files when the values are missing. Thanks to :user:`autrimpo`.