diff --git a/README.md b/README.md index a20910d..ea30a55 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,12 @@ Unfortunately the Cassandra project does not always increment the `cqlsh` versio release we need to document not only the `cqlsh` version but also the `cassandra` version in which it shipped. +#### 6.1.1 (March 22, 2023) + +This packages `cqlsh` `6.1.0` from [Cassandra 4.1.1](https://github.com/apache/cassandra/blob/cassandra-4.1.0/bin/cqlsh.py): +* Now supports Python 3.11. +* Although this is pulled from a Cassandra `4.x` release, it is protocol compatible with Cassandra `3.x` clusters, with the exception of DESCRIBE keywords which require a 4.x cluster. + #### 6.1.0 (Jan 4, 2023) This packages `cqlsh` `6.1.0` from [Cassandra 4.1](https://github.com/apache/cassandra/blob/cassandra-4.1.0/bin/cqlsh.py): diff --git a/cqlshlib/formatting.py b/cqlshlib/formatting.py index b49a29a..ebf9fc7 100644 --- a/cqlshlib/formatting.py +++ b/cqlshlib/formatting.py @@ -440,7 +440,7 @@ def append(builder, dividend, divisor, unit): if dividend == 0 or dividend < divisor: return dividend - builder.append(str(dividend / divisor)) + builder.append(str(dividend // divisor)) builder.append(unit) return dividend % divisor diff --git a/cqlshlib/saferscanner.py b/cqlshlib/saferscanner.py index 3cc3430..5afd8ef 100644 --- a/cqlshlib/saferscanner.py +++ b/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 @@ def __init__(self, lexicon, flags=0): 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 diff --git a/setup.cfg b/setup.cfg index 420db07..3d174a0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -22,6 +22,8 @@ classifiers = Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 + Programming Language :: Python :: 3.10 + Programming Language :: Python :: 3.11 [options] packages = cqlsh, cqlshlib