Skip to content

Commit

Permalink
Fixes some client.py exceptions for Python 3.
Browse files Browse the repository at this point in the history
This fixes two problems:

1) The exception syntax rework incorrectly updated two except clauses
to use the new *raise* syntax rather than the new *except* syntax.

2) In Python 3, exception objects are local to the try/except block,
making them inaccessible outside that block.  It was probably actually
an error to set the "message" to be the exception object rather than
its string representation, anyway.

TESTED:
Ran xgps without gpsd running, and verified that the proper error box
is displayed, in both Python 2 and Python 3 (with appropriate builds
of the extensions).  Didn't test the gpsjson.unpack ValueError case,
but the syntax is the same.
  • Loading branch information
fhgwright committed Apr 6, 2016
1 parent 985efb4 commit 9f5f5ab
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions gps/client.py
Expand Up @@ -67,7 +67,8 @@ def connect(self, host, port):
self.sock = socket.socket(af, socktype, proto)
# if self.debuglevel > 0: print 'connect:', (host, port)
self.sock.connect(sa)
except socket.error(msg):
except socket.error as e:
msg = str(e)
# if self.debuglevel > 0: print 'connect fail:', (host, port)
self.close()
continue
Expand Down Expand Up @@ -161,7 +162,7 @@ def __iter__(self):
def unpack(self, buf):
try:
self.data = dictwrapper(json.loads(buf.strip(), encoding="ascii"))
except ValueError(e):
except ValueError as e:
raise json_error(buf, e.args[0])
# Should be done for any other array-valued subobjects, too.
# This particular logic can fire on SKY or RTCM2 objects.
Expand Down

0 comments on commit 9f5f5ab

Please sign in to comment.