From b7eb87a397ed7b1b6271b5d171c231ea19ad0d75 Mon Sep 17 00:00:00 2001 From: Alex O'Rourke Date: Mon, 26 Oct 2015 15:09:39 -0700 Subject: [PATCH] Changes exception's isinstance str to basestring The error description was not being displayed when an exception was being raised. This was due to the patch merged in from issue #12 (reported in the 3PAR client), which changed the body to type bytes instead of typestr. The check in exceptions.py is now updated to represent this change. Change-Id: I471192a38b47f118114239fce63c52c9764b1ac9 --- docs/changelog.rst | 2 ++ hpelefthandclient/exceptions.py | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index cdede51..5a6acde 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -92,3 +92,5 @@ Changes in Version 2.0.1 ------------------------ * Allows suppressing of InsecureRequestWarning messages +* Changes the exception isinstance check to look for basestring/str instead of + bytes in order to properly store the error description. diff --git a/hpelefthandclient/exceptions.py b/hpelefthandclient/exceptions.py index f237085..7a25528 100644 --- a/hpelefthandclient/exceptions.py +++ b/hpelefthandclient/exceptions.py @@ -24,6 +24,12 @@ Exceptions for the client the REST calls """ +# Python 3+ override +try: + basestring +except NameError: + basestring = str + class UnsupportedVersion(Exception): """ @@ -65,7 +71,7 @@ class ClientException(Exception): if not error: return - if isinstance(error, str): + if isinstance(error, basestring): # instead of KeyError below, take it and make it the _error_desc. self._error_desc = error else: