gpsd-dev
[Top][All Lists]
Advanced

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

[gpsd-dev] [PATCH 03/12] Forces Python 3 import behavior in all gps/* mo


From: Fred Wright
Subject: [gpsd-dev] [PATCH 03/12] Forces Python 3 import behavior in all gps/* modules.
Date: Fri, 8 Apr 2016 10:07:44 -0700

This ensures that any future changes that accidentally rely on the
Python 2 implicit relative import behavior will fail in Python 2 as
well as Python 3.

TESTED:
Ran "scons build-all check" (with Python 2.7).  Also verified that the
regression tests and test_maidenhead.py run with Python 2.6, and that
gpsfake -T and test_maidenhead.py run with Python 3 when the
extensions are built for Python 3 (not yet a build option).
---
 gps/__init__.py | 2 ++
 gps/client.py   | 2 +-
 gps/fake.py     | 2 +-
 gps/gps.py      | 2 +-
 gps/misc.py     | 2 +-
 5 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/gps/__init__.py b/gps/__init__.py
index 05bce89..4292098 100644
--- a/gps/__init__.py
+++ b/gps/__init__.py
@@ -3,6 +3,8 @@
 # This file is Copyright (c) 2010 by the GPSD project
 # BSD terms apply: see the file COPYING in the distribution root for details.
 
+from __future__ import absolute_import  # Ensure Python2 behaves like Python 3
+
 api_major_version = 5   # bumped on incompatible changes
 api_minor_version = 0   # bumped on compatible changes
 
diff --git a/gps/client.py b/gps/client.py
index 8f8ed91..ec9d100 100644
--- a/gps/client.py
+++ b/gps/client.py
@@ -3,7 +3,7 @@
 #
 # This code run compatibly under Python 2 and 3.x for x >= 3.
 # Preserve this property!
-from __future__ import print_function, division
+from __future__ import absolute_import, print_function, division
 
 import time, socket, sys, select, json
 
diff --git a/gps/fake.py b/gps/fake.py
index 7041dda..144edd9 100644
--- a/gps/fake.py
+++ b/gps/fake.py
@@ -69,7 +69,7 @@ the run method in a subthread, with locking of critical 
regions.
 """
 # This code run compatibly under Python 2 and 3.x for x >= 3.
 # Preserve this property!
-from __future__ import print_function, division
+from __future__ import absolute_import, print_function, division
 
 import os, sys, time, signal, pty, termios  # fcntl, array, struct
 import threading, socket, select
diff --git a/gps/gps.py b/gps/gps.py
index 4935d8c..35a3707 100755
--- a/gps/gps.py
+++ b/gps/gps.py
@@ -17,7 +17,7 @@
 
 # This code run compatibly under Python 2 and 3.x for x >= 3.
 # Preserve this property!
-from __future__ import print_function, division
+from __future__ import absolute_import, print_function, division
 
 from .client import *
 from .misc import isotime
diff --git a/gps/misc.py b/gps/misc.py
index 51a8bb8..eb9fe9d 100644
--- a/gps/misc.py
+++ b/gps/misc.py
@@ -5,7 +5,7 @@
 
 # This code run compatibly under Python 2 and 3.x for x >= 3.
 # Preserve this property!
-from __future__ import print_function, division
+from __future__ import absolute_import, print_function, division
 
 import time, calendar, math
 
-- 
2.8.0




reply via email to

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