[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
- [gpsd-dev] Python 3 Updates, Fred Wright, 2016/04/08
- [gpsd-dev] [PATCH 01/12] Fixes Python C extensions for Python 3 compatibility., Fred Wright, 2016/04/08
- [gpsd-dev] [PATCH 02/12] Fixes fake.py 'packet' import for Python 3., Fred Wright, 2016/04/08
- [gpsd-dev] [PATCH 04/12] Fixes xgps for Python 3., Fred Wright, 2016/04/08
- [gpsd-dev] [PATCH 05/12] Fixes a client.py exception for Python 3., Fred Wright, 2016/04/08
- [gpsd-dev] [PATCH 06/12] Fixes Gtk warnings related to xgps/xgpsspeed error boxes., Fred Wright, 2016/04/08
- [gpsd-dev] [PATCH 07/12] Changes type checks in misc.py:isotime to use isinstance()., Fred Wright, 2016/04/08
- [gpsd-dev] [PATCH 03/12] Forces Python 3 import behavior in all gps/* modules.,
Fred Wright <=
- [gpsd-dev] [PATCH 09/12] Fixes gpscat and test_maidenhead.py for Python 3., Fred Wright, 2016/04/08
- [gpsd-dev] [PATCH 08/12] Removes unnecessary Unicode literal from xgps., Fred Wright, 2016/04/08
- [gpsd-dev] [PATCH 10/12] Fixes fake.py and gpsfake for Python 3., Fred Wright, 2016/04/08
- [gpsd-dev] [PATCH 12/12] Removes redundant polystr/polybytes defs from client.py., Fred Wright, 2016/04/08
- [gpsd-dev] [PATCH 11/12] Adds "target Python" support to SConstruct., Fred Wright, 2016/04/08
- Re: [gpsd-dev] Python 3 Updates, Gary E. Miller, 2016/04/08
- Re: [gpsd-dev] Python 3 Updates, Eric S. Raymond, 2016/04/09