Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions pyeapi/eapilib.py
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

Original file line number Diff line number Diff line change
Expand Up @@ -442,10 +442,8 @@ def send(self, data):
raise ConnectionError(str(self), '%s. %s' % (response.reason,
response_content))

# Work around for Python 2.7/3.x compatibility
if not type(response_content) == str:
# For Python 3.x - decode bytes into string
response_content = response_content.decode()
# Python 3.7 json.loads() works with bytes or strings,
# thus no decoding is required
decoded = json.loads(response_content)
_LOGGER.debug('eapi_response: %s' % decoded)

Expand All @@ -462,8 +460,8 @@ def send(self, data):

return decoded

# socket.error is deprecated in python 3 and replaced with OSError.
except (socket.error, OSError) as exc:
# removed socket.error as it's deprecated in python 3
except OSError as exc:
_LOGGER.exception(exc)
self.socket_error = exc
self.error = exc
Expand Down Expand Up @@ -726,7 +724,7 @@ def authentication(self, username, password):
session = SimpleCookie(resp.getheader("Set-Cookie"))
self._auth = ("Cookie", session.output(header="", attrs=[]))

except (socket.error, OSError) as exc:
except OSError as exc:
_LOGGER.exception(exc)
self.socket_error = exc
self.error = exc
Expand Down
2 changes: 1 addition & 1 deletion pyeapi/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def make_iterable(value):
iterable in the form of a list.

Args:
value (object): An valid Python object
value (object): A valid Python object

Returns:
An iterable object of type list
Expand Down