This is an automated email from the ASF dual-hosted git repository. brandonwilliams pushed a commit to branch cassandra-4.0 in repository https://gitbox.apache.org/repos/asf/cassandra.git
commit 0b5248d8c3ef743a8dda42f7be5dadb70e373b51 Author: Brandon Williams <brandonwilli...@apache.org> AuthorDate: Sun Dec 4 13:05:19 2022 -0600 Accommodate python 3.11 Patch by brandonwilliams; reviewed by bereng for CASSANDRA-18088 --- CHANGES.txt | 1 + pylib/cqlshlib/saferscanner.py | 26 ++++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index d51e991e34..8794ae533a 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 4.0.8 + * Add support for python 3.11 (CASSANDRA-18088) * Fix formatting of duration in cqlsh (CASSANDRA-18141) * Fix sstable loading of keyspaces named snapshots or backups (CASSANDRA-14013) * Avoid ConcurrentModificationException in STCS/DTCS/TWCS.getSSTables (CASSANDRA-17977) diff --git a/pylib/cqlshlib/saferscanner.py b/pylib/cqlshlib/saferscanner.py index 8949321dff..6d7ba571af 100644 --- a/pylib/cqlshlib/saferscanner.py +++ b/pylib/cqlshlib/saferscanner.py @@ -20,7 +20,10 @@ import re import six -from sre_constants import BRANCH, SUBPATTERN, GROUPREF, GROUPREF_IGNORE, GROUPREF_EXISTS +try: + from sre_constants import BRANCH, SUBPATTERN, GROUPREF, GROUPREF_IGNORE, GROUPREF_EXISTS +except ImportError: + from re._constants import BRANCH, SUBPATTERN, GROUPREF, GROUPREF_IGNORE, GROUPREF_EXISTS from sys import version_info @@ -99,5 +102,24 @@ class Py38SaferScanner(SaferScannerBase): self.scanner = re.sre_compile.compile(p) +class Py311SaferScanner(SaferScannerBase): + + def __init__(self, lexicon, flags=0): + self.lexicon = lexicon + p = [] + s = re._parser.State() + s.flags = flags + for phrase, action in lexicon: + gid = s.opengroup() + p.append(re._parser.SubPattern(s, [(SUBPATTERN, (gid, 0, 0, re._parser.parse(phrase, flags))), ])) + s.closegroup(gid, p[-1]) + p = re._parser.SubPattern(s, [(BRANCH, (None, p))]) + self.p = p + self.scanner = re._compiler.compile(p) + + SaferScanner = Py36SaferScanner if six.PY3 else Py2SaferScanner -SaferScanner = Py38SaferScanner if version_info >= (3, 8) else SaferScanner +if version_info >= (3, 11): + SaferScanner = Py311SaferScanner +elif version_info >= (3, 8): + SaferScanner = Py38SaferScanner --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org