This is an automated email from the ASF dual-hosted git repository. stefania pushed a commit to branch cassandra-2.1 in repository https://gitbox.apache.org/repos/asf/cassandra.git
The following commit(s) were added to refs/heads/cassandra-2.1 by this push: new f3568c0 Fix parse error in cqlsh COPY FROM and formatting for map of blobs f3568c0 is described below commit f3568c0d50ac7573b53f0043b2567bde3b39bee8 Author: Aleksandr Sorokoumov <aleksandr.sorokou...@gmail.com> AuthorDate: Wed Apr 1 16:32:52 2020 +0200 Fix parse error in cqlsh COPY FROM and formatting for map of blobs patch by Aleksandr Sorokoumov; reviewed by Stefania Alborghetti for CASSANDRA-15679 --- CHANGES.txt | 1 + pylib/cqlshlib/copyutil.py | 8 ++------ pylib/cqlshlib/formatting.py | 9 ++++++++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 3582d4f..d0d0993 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 2.1.21 + * Fix parse error in cqlsh COPY FROM and formatting for map of blobs (CASSANDRA-15679) * Paged Range Slice queries with DISTINCT can drop rows from results (CASSANDRA-14956) * Update release checksum algorithms to SHA-256, SHA-512 (CASSANDRA-14970) * Check checksum before decompressing data (CASSANDRA-14284) diff --git a/pylib/cqlshlib/copyutil.py b/pylib/cqlshlib/copyutil.py index 85e2678..a8bd0a2 100644 --- a/pylib/cqlshlib/copyutil.py +++ b/pylib/cqlshlib/copyutil.py @@ -52,7 +52,7 @@ from cassandra.util import Date, Time from cql3handling import CqlRuleSet from displaying import NO_COLOR_MAP -from formatting import format_value_default, EMPTY, get_formatter +from formatting import format_value_default, EMPTY, get_formatter, BlobType from sslhandling import ssl_settings PROFILE_ON = False @@ -1726,11 +1726,7 @@ class ImportConversion(object): return converters.get(t.typename, convert_unknown)(v, ct=t) def convert_blob(v, **_): - try: - return bytearray.fromhex(v[2:]) - except TypeError: - # Work-around for Python 2.6 bug - return bytearray.fromhex(unicode(v[2:])) + return BlobType(unicode(v[2:]).decode("hex")) def convert_text(v, **_): return v diff --git a/pylib/cqlshlib/formatting.py b/pylib/cqlshlib/formatting.py index eac1810..436404a 100644 --- a/pylib/cqlshlib/formatting.py +++ b/pylib/cqlshlib/formatting.py @@ -126,13 +126,20 @@ def formatter_for(typname): return f return registrator +class BlobType(object): + def __init__(self, val): + self.val = val -@formatter_for('bytearray') + def __str__(self): + return str(self.val) + +@formatter_for('BlobType') def format_value_blob(val, colormap, **_): bval = '0x' + binascii.hexlify(str(val)) return colorme(bval, colormap, 'blob') +formatter_for('bytearray')(format_value_blob) formatter_for('buffer')(format_value_blob) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org