From 65e3624091e895ca32cd91468552589f34d17595 Mon Sep 17 00:00:00 2001 From: Aravinda VK Date: Fri, 14 Jun 2019 16:11:37 +0530 Subject: eventsapi: Fix Exception class for Python3 Python2 exception provides message attribute for custom exceptions. But it is not available in Python3. Add init method for custom exception to handle the same. Original crash(IndexError reported in the bug) was fixed with https://review.gluster.org/#/c/glusterfs/+/22294/ But that patch only works in Python2 and fails in Python3 since Exception in Python 3 doesn't have "message" attribute. Fixes: bz#1573226 Change-Id: If9117048f9ff0615f5da1880075ec12c0ff4855e Signed-off-by: Aravinda VK --- extras/cliutils/cliutils.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'extras') diff --git a/extras/cliutils/cliutils.py b/extras/cliutils/cliutils.py index 0095586827d..55fbaf56704 100644 --- a/extras/cliutils/cliutils.py +++ b/extras/cliutils/cliutils.py @@ -20,7 +20,14 @@ _common_args_func = lambda p: True class GlusterCmdException(Exception): - pass + def __init__(self, message): + self.message = message + try: + # Python 3 + super().__init__(message) + except TypeError: + # Python 2 + super(GlusterCmdException, self).__init__(message) def get_node_uuid(): -- cgit