You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by br...@apache.org on 2023/01/20 21:28:39 UTC
[cassandra] 01/04: Accommodate python 3.11
This is an automated email from the ASF dual-hosted git repository.
brandonwilliams pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git
commit 25e4a89f76917076f0be56fb2b098a7d8f5ba06b
Author: Brandon Williams <br...@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 | 28 ++++++++++++++++++++++++++--
2 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/CHANGES.txt b/CHANGES.txt
index 36934c6454..610423f67f 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -102,6 +102,7 @@ Merged from 4.1:
* Streaming progress virtual table lock contention can trigger TCP_USER_TIMEOUT and fail streaming (CASSANDRA-18110)
* Fix perpetual load of denylist on read in cases where denylist can never be loaded (CASSANDRA-18116)
Merged from 4.0:
+ * 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 3cc343033a..5afd8ef172 100644
--- a/pylib/cqlshlib/saferscanner.py
+++ b/pylib/cqlshlib/saferscanner.py
@@ -19,7 +19,11 @@
# regex in-pattern flags. Any of those can break correct operation of Scanner.
import re
-from sre_constants import BRANCH, SUBPATTERN, GROUPREF, GROUPREF_IGNORE, GROUPREF_EXISTS
+import six
+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
@@ -81,4 +85,24 @@ class Py38SaferScanner(SaferScannerBase):
self.scanner = re.sre_compile.compile(p)
-SaferScanner = Py38SaferScanner if version_info >= (3, 8) else Py36SaferScanner
+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
+if version_info >= (3, 11):
+ SaferScanner = Py311SaferScanner
+elif version_info >= (3, 8):
+ SaferScanner = Py38SaferScanner
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org