Skip to content

Commit

Permalink
Fix Python 3.7 compatibility (#2978)
Browse files Browse the repository at this point in the history
  • Loading branch information
sampsyo committed Jul 22, 2018
1 parent 4f156b9 commit 15d44f0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 7 additions & 1 deletion beets/autotag/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@

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.

Expand Down Expand Up @@ -433,7 +439,7 @@ def _eq(self, value1, value2):
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

Expand Down
2 changes: 2 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down

0 comments on commit 15d44f0

Please sign in to comment.