gpsd-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gpsd-dev] [PATCH 4/4] Changes fake.py subclasses to use super() in __in


From: Fred Wright
Subject: [gpsd-dev] [PATCH 4/4] Changes fake.py subclasses to use super() in __init__().
Date: Sun, 10 Apr 2016 19:29:08 -0700

This doesn't really change any behavior, but serves as a better
example for future code.  Note that this can't be done so easily for
gps.gps, due to the mismatched init signatures.

This uses the older super() syntax, which is compatible with both
Python 2 and Python 3.

TESTED:
Ran "scons build-all check" with all six supported Python versions.
Also tested exception objects manually.
---
 gps/fake.py | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/gps/fake.py b/gps/fake.py
index aa6db17..830b1e9 100644
--- a/gps/fake.py
+++ b/gps/fake.py
@@ -121,7 +121,7 @@ def GetDelay(slow=False):
 
 class TestLoadError(BaseException):
     def __init__(self, msg):
-        BaseException.__init__(self)
+        super(TestLoadError, self).__init__()
         self.msg = msg
 
 
@@ -217,7 +217,7 @@ class TestLoad(object):
 
 class PacketError(BaseException):
     def __init__(self, msg):
-        BaseException.__init__(self)
+        super(PacketError, self).__init__()
         self.msg = msg
 
 
@@ -253,7 +253,7 @@ class FakePTY(FakeGPS):
     def __init__(self, testload,
                  speed=4800, databits=8, parity='N', stopbits=1,
                  progress=None):
-        FakeGPS.__init__(self, testload, progress)
+        super(FakePTY, self).__init__(testload, progress)
         # Allow Serial: header to be overridden by explicit speed.
         if self.testload.serial:
             (speed, databits, parity, stopbits) = self.testload.serial
@@ -361,7 +361,7 @@ class FakeTCP(FakeGPS):
     def __init__(self, testload,
                  host, port,
                  progress=None):
-        FakeGPS.__init__(self, testload, progress)
+        super(FakeTCP, self).__init__(testload, progress)
         self.host = host
         self.dispatcher = cleansocket(self.host, int(port))
         self.port = self.dispatcher.getsockname()[1]  # Get actual assigned 
port
@@ -408,7 +408,7 @@ class FakeUDP(FakeGPS):
     def __init__(self, testload,
                  ipaddr, port,
                  progress=None):
-        FakeGPS.__init__(self, testload, progress)
+        super(FakeUDP, self).__init__(testload, progress)
         self.ipaddr = ipaddr
         self.port = port
         self.byname = "udp://" + ipaddr + ":" + str(port)
@@ -429,7 +429,7 @@ class FakeUDP(FakeGPS):
 
 class DaemonError(BaseException):
     def __init__(self, msg):
-        BaseException.__init__(self)
+        super(DaemonError, self).__init__()
         self.msg = msg
 
     def __str__(self):
@@ -554,7 +554,7 @@ class DaemonInstance(object):
 
 class TestSessionError(BaseException):
     def __init__(self, msg):
-        BaseException.__init__(self)
+        super(TestSessionError, self).__init__()
         self.msg = msg
 
 
-- 
2.8.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]