summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFred Wright <fw@fwright.net>2016-04-10 19:29:05 -0700
committerEric S. Raymond <esr@thyrsus.com>2016-04-11 03:24:04 -0400
commitdaf3a92073b296559fdba732b29ab8d1a2f3c07c (patch)
treeb95ed0b12686d7b54e08ef83de0ca47011ccb7c6
parentcbe211fda926cee23bde9bbb59f364a540f5a155 (diff)
downloadgpsd-daf3a92073b296559fdba732b29ab8d1a2f3c07c.tar.gz
Fixes gps/*.py to use new-style classes.
Although this isn't strictly a Python 3 requirement, using the new-style class definition syntax improves consistency between Python 2 and Python 3. Old-style classes have been deprecated since Python 2.2, but many such definitions linger on. Python 3 eliminates old-style classes, but instead of complaining about old-style definitions, it simply unconditionally and silently makes all classes new-style. The only incompatible differences are quite subtle and rarely matter in practice, but things are more consistent across versions if the new-style definitions are used. Also, the preferred method for subclasses to invoke parent init methods is via the super() construct, which is only available with new-style classes. Using super() is especially useful with multiple inheritance, which it handles automatically (provided that the init methods have compatible signatures). TESTED: Ran "scons build-all check valgrind-audit", as well as gegps, gpscat, gpsprof, xgps, and xgpsspeed, with all six supported Python versions (except 2.6 for xgps*).
-rw-r--r--gps/client.py6
-rw-r--r--gps/fake.py8
-rwxr-xr-xgps/gps.py4
3 files changed, 9 insertions, 9 deletions
diff --git a/gps/client.py b/gps/client.py
index 88d8054f..3825bcf7 100644
--- a/gps/client.py
+++ b/gps/client.py
@@ -11,7 +11,7 @@ from .misc import polystr, polybytes
GPSD_PORT = "2947"
-class gpscommon:
+class gpscommon(object):
"Isolate socket handling and buffering from the protocol interpretation."
def __init__(self, host="127.0.0.1", port=GPSD_PORT, verbose=0):
@@ -134,7 +134,7 @@ WATCH_PPS = 0x002000 # enable PPS in raw/NMEA
WATCH_DEVICE = 0x000800 # watch specific device
-class gpsjson:
+class gpsjson(object):
"Basic JSON decoding."
def __iter__(self):
@@ -193,7 +193,7 @@ class gpsjson:
return self.send(arg + "}")
-class dictwrapper:
+class dictwrapper(object):
"Wrapper that yields both class and dictionary behavior,"
def __init__(self, ddict):
diff --git a/gps/fake.py b/gps/fake.py
index 88336d32..aa6db174 100644
--- a/gps/fake.py
+++ b/gps/fake.py
@@ -125,7 +125,7 @@ class TestLoadError(BaseException):
self.msg = msg
-class TestLoad:
+class TestLoad(object):
"Digest a logfile into a list of sentences we can cycle through."
def __init__(self, logfp, predump=False, slow=False, oneshot=False):
@@ -221,7 +221,7 @@ class PacketError(BaseException):
self.msg = msg
-class FakeGPS:
+class FakeGPS(object):
def __init__(self, testload, progress=None):
self.testload = testload
self.progress = progress
@@ -436,7 +436,7 @@ class DaemonError(BaseException):
return repr(self.msg)
-class DaemonInstance:
+class DaemonInstance(object):
"Control a gpsd instance."
def __init__(self, control_socket=None):
@@ -558,7 +558,7 @@ class TestSessionError(BaseException):
self.msg = msg
-class TestSession:
+class TestSession(object):
"Manage a session including a daemon with fake GPSes and clients."
def __init__(self, prefix=None, port=None, options=None, verbose=0, predump=False, udp=False, tcp=False, slow=False):
diff --git a/gps/gps.py b/gps/gps.py
index bc66f7cb..a0868afc 100755
--- a/gps/gps.py
+++ b/gps/gps.py
@@ -87,7 +87,7 @@ WATCH_NEWSTYLE = 0x010000 # force JSON streaming
WATCH_OLDSTYLE = 0x020000 # force old-style streaming
-class gpsfix:
+class gpsfix(object):
def __init__(self):
self.mode = MODE_NO_FIX
self.time = NaN
@@ -105,7 +105,7 @@ class gpsfix:
self.epc = NaN
-class gpsdata:
+class gpsdata(object):
"Position, track, velocity and status information returned by a GPS."
class satellite: