You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by st...@apache.org on 2020/04/09 15:46:31 UTC

[cassandra] branch trunk updated: Use Exception.message in copyutil.py only if it exists

This is an automated email from the ASF dual-hosted git repository.

stefania 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 58015fd  Use Exception.message in copyutil.py only if it exists
58015fd is described below

commit 58015fd681dadbe31068ecfb4f4c0eb506de8efa
Author: Eduard Tudenhoefner <ed...@datastax.com>
AuthorDate: Tue Apr 7 17:16:40 2020 +0200

    Use Exception.message in copyutil.py only if it exists
    
    Exception.message was removed in Python 3, so only refer to it when it
    exists on an Exception instance.
    
    Also fix code style compliance in formatting.py (missing blank lines)
    
    patch by Eduard Tudenhoefner; reviewed by Stefania Alborghetti for CASSANDRA-15702
---
 pylib/cqlshlib/copyutil.py   | 8 ++++----
 pylib/cqlshlib/formatting.py | 2 ++
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/pylib/cqlshlib/copyutil.py b/pylib/cqlshlib/copyutil.py
index 853893c..169a6e0 100644
--- a/pylib/cqlshlib/copyutil.py
+++ b/pylib/cqlshlib/copyutil.py
@@ -146,7 +146,7 @@ class SendingChannel(object):
                     msg = self.pending_messages.get()
                     self.pipe.send(msg)
                 except Exception as e:
-                    printmsg('%s: %s' % (e.__class__.__name__, e.message))
+                    printmsg('%s: %s' % (e.__class__.__name__, e.message if hasattr(e, 'message') else str(e)))
 
         feeding_thread = threading.Thread(target=feed)
         feeding_thread.setDaemon(True)
@@ -1342,7 +1342,7 @@ class FeedingProcess(mp.Process):
         try:
             reader.start()
         except IOError as exc:
-            self.outmsg.send(ImportTaskError(exc.__class__.__name__, exc.message))
+            self.outmsg.send(ImportTaskError(exc.__class__.__name__, exc.message if hasattr(exc, 'message') else str(exc)))
 
         channels = self.worker_channels
         max_pending_chunks = self.max_pending_chunks
@@ -1371,7 +1371,7 @@ class FeedingProcess(mp.Process):
                     if rows:
                         sent += self.send_chunk(ch, rows)
                 except Exception as exc:
-                    self.outmsg.send(ImportTaskError(exc.__class__.__name__, exc.message))
+                    self.outmsg.send(ImportTaskError(exc.__class__.__name__, exc.message if hasattr(exc, 'message') else str(exc)))
 
                 if reader.exhausted:
                     break
@@ -2632,7 +2632,7 @@ class ImportProcess(ChildProcess):
                 pk = get_row_partition_key_values(row)
                 rows_by_ring_pos[get_ring_pos(ring, pk_to_token_value(pk))].append(row)
             except Exception as e:
-                errors[e.message].append(row)
+                errors[e.message if hasattr(e, 'message') else str(e)].append(row)
 
         if errors:
             for msg, rows in errors.items():
diff --git a/pylib/cqlshlib/formatting.py b/pylib/cqlshlib/formatting.py
index e00d91f..a8ee51d 100644
--- a/pylib/cqlshlib/formatting.py
+++ b/pylib/cqlshlib/formatting.py
@@ -239,6 +239,7 @@ def formatter_for(typname):
         return f
     return registrator
 
+
 class BlobType(object):
     def __init__(self, val):
         self.val = val
@@ -246,6 +247,7 @@ class BlobType(object):
     def __str__(self):
         return str(self.val)
 
+
 @formatter_for('BlobType')
 def format_value_blob(val, colormap, **_):
     bval = ensure_text('0x') + ensure_text(binascii.hexlify(val))


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org