Skip to content

Commit

Permalink
Merge pull request #27 from bschoening/master
Browse files Browse the repository at this point in the history
Cassandra 4.1.1
  • Loading branch information
bschoening authored Mar 22, 2023
2 parents b41ee79 + 36e2cc4 commit 4d33750
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 3 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion cqlshlib/formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
28 changes: 26 additions & 2 deletions cqlshlib/saferscanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4d33750

Please sign in to comment.