Skip to content

Commit

Permalink
<exception>.message is no longer a thing in Python3
Browse files Browse the repository at this point in the history
I've encountered today an error, looking like:

```
'UnlockError' object has no attribute 'messsage'!
```

It look like we still have some small Python2 remains, as
<exception>.message is no longer valid syntax in Python3 (surprised that
the linter didn't catch that).
  • Loading branch information
mirceaulinic committed Jul 9, 2019
1 parent 17b7ba2 commit 695bf1e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions napalm/junos/junos.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def _unlock(self):
self.device.cu.unlock()
self.locked = False
except JnrpUnlockError as jue:
raise UnlockError(jue.messsage)
raise UnlockError(jue)

def _rpc(self, get, child=None, **kwargs):
"""
Expand Down Expand Up @@ -818,7 +818,7 @@ def get_lldp_neighbors_detail(self, interface=""):
interface_args = {interface_variable: interface}
lldp_table.get(**interface_args)
except RpcError as e:
if "syntax error" in e.message:
if "syntax error" in str(e):
# Looks like we need to call a different RPC on this device
# Switch to the alternate style
lldp_table.GET_RPC = alt_rpc
Expand Down Expand Up @@ -1571,7 +1571,7 @@ def get_mac_address_table(self):
except RpcError as e:
# Device hasn't got it's l2 subsystem running
# Don't error but just return an empty result
if "l2-learning subsystem" in e.message:
if "l2-learning subsystem" in str(e):
return []
else:
raise
Expand Down

0 comments on commit 695bf1e

Please sign in to comment.