This is an automated email from the ASF dual-hosted git repository.
mck pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git
The following commit(s) were added to refs/heads/trunk by this push:
new 24c8a21 Add Python3.8 compatible SaferScanner
24c8a21 is described below
commit 24c8a21c1c131abd89c6b646343ff098d1b3263b
Author: Eduard Tudenhoefner <[email protected]>
AuthorDate: Mon Apr 6 17:36:03 2020 +0200
Add Python3.8 compatible SaferScanner
This is necessary because Python 3.8 renamed `sre_parse.Pattern` to
`sre_parse.State` (see https://bugs.python.org/issue34681 and
https://github.com/python/cpython/pull/9310/files for details)
patch by Eduard Tudenhöfner, reviewed by Mick Semb Wever for
CASSANDRA-15573
---
CHANGES.txt | 2 +-
pylib/cqlshlib/saferscanner.py | 17 +++++++++++++++++
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/CHANGES.txt b/CHANGES.txt
index 958ee99..5dd25e4 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,5 +1,5 @@
4.0-alpha4
- * Allow cqlsh to run with Python2.7/Python3.6+ (CASSANDRA-15659)
+ * Allow cqlsh to run with Python2.7/Python3.6+
(CASSANDRA-15659,CASSANDRA-15573)
* Improve logging around incremental repair (CASSANDRA-15599)
* Do not check cdc_raw_directory filesystem space if CDC disabled
(CASSANDRA-15688)
* Replace array iterators with get by index (CASSANDRA-15394)
diff --git a/pylib/cqlshlib/saferscanner.py b/pylib/cqlshlib/saferscanner.py
index e559f1c..75b5df7 100644
--- a/pylib/cqlshlib/saferscanner.py
+++ b/pylib/cqlshlib/saferscanner.py
@@ -21,6 +21,7 @@
import re
import six
from sre_constants import BRANCH, SUBPATTERN, GROUPREF, GROUPREF_IGNORE,
GROUPREF_EXISTS
+from sys import version_info
class SaferScannerBase(re.Scanner):
@@ -82,4 +83,20 @@ class Py36SaferScanner(SaferScannerBase):
self.scanner = re.sre_compile.compile(p)
+class Py38SaferScanner(SaferScannerBase):
+
+ def __init__(self, lexicon, flags=0):
+ self.lexicon = lexicon
+ p = []
+ s = re.sre_parse.State()
+ s.flags = flags
+ for phrase, action in lexicon:
+ gid = s.opengroup()
+ p.append(re.sre_parse.SubPattern(s, [(SUBPATTERN, (gid, 0, 0,
re.sre_parse.parse(phrase, flags))), ]))
+ s.closegroup(gid, p[-1])
+ p = re.sre_parse.SubPattern(s, [(BRANCH, (None, p))])
+ self.p = p
+ self.scanner = re.sre_compile.compile(p)
+
SaferScanner = Py36SaferScanner if six.PY3 else Py2SaferScanner
+SaferScanner = Py38SaferScanner if version_info >= (3, 8) else SaferScanner
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]