From 79991ff14b9e396e319e108d7615d379163347d9 Mon Sep 17 00:00:00 2001 From: Fred Wright Date: Fri, 8 Apr 2016 10:07:50 -0700 Subject: Fixes gpscat and test_maidenhead.py for Python 3. This fixes two issues with gpscat in Python 3: 1) The data accumulation buffer needs to be 'bytes' rather than a 'str' in Python 3. This is easily accomplished by using bytes() as the initializer/reinitializer. 2) The hexdump routine (which was also iterating in a rather strange way) needs to obtain int values for the characters of the buffer in a 2/3-independent manner. This is easily accomplished by converting it to a bytearray, which works in both Python 2 and Python 3. This isn't exactly the same as the Python 3 'bytes' type, since it's unnecessarily mutable, but it's an easy fix that doesn't require version conditionals. Also, test_maidenhead.py works with Python 3 after updating the libraries, so the shebang line and comments now reflect that. TESTED: Ran them under Python 2.6, 2.7, and 3.2-3.5 (with appropriate builds of the extensions). --- test_maidenhead.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'test_maidenhead.py') diff --git a/test_maidenhead.py b/test_maidenhead.py index e8d5459d..13b64475 100755 --- a/test_maidenhead.py +++ b/test_maidenhead.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python # # Test grid locator conversion. # @@ -7,6 +7,8 @@ # Test conversions generated using # http://f6fvy.free.fr/qthLocator/ +# This code runs compatibly under Python 2 and 3.x for x >= 2. +# Preserve this property! from __future__ import print_function import sys, gps.clienthelpers -- cgit v1.2.1