Skip to content

Commit

Permalink
Fix regexp global tokens not at pattern start issue
Browse files Browse the repository at this point in the history
Python 3.12 complains about `(?x)` flag not being located at the beginning of
the pattern.

Note: May be relevant for packagecontrol.io which also uses parts of this plugin.
  • Loading branch information
deathaxe committed Jul 19, 2023
1 parent 85c6590 commit 62360ad
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions package_control/deps/semver.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,14 @@ class SemVer(namedtuple("_SemVer", 'major, minor, patch, prerelease, build')):
"""

# Static class variables
_base_regex = r'''(?x)
_base_regex = r'''
(?P<major>[0-9]+)
\.(?P<minor>[0-9]+)
\.(?P<patch>[0-9]+)
(?:\-(?P<prerelease>(?:[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?))?
(?:\+(?P<build>(?:[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?))?'''
_search_regex = re.compile(_base_regex)
_match_regex = re.compile('^%s$' % _base_regex) # required because of $ anchor
_search_regex = re.compile(r'(?x)%s' % _base_regex)
_match_regex = re.compile(r'(?x)^%s$' % _base_regex) # required because of $ anchor

# "Constructor"
def __new__(cls, *args, **kwargs):
Expand Down

0 comments on commit 62360ad

Please sign in to comment.