diff options
author | Fred Wright <fw@fwright.net> | 2016-04-08 10:07:50 -0700 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2016-04-09 04:39:16 -0400 |
commit | 79991ff14b9e396e319e108d7615d379163347d9 (patch) | |
tree | a2dc27580b51e98e22f2d7f1c403a7a0e0a51388 /test_maidenhead.py | |
parent | d79ddb4f02f8800fe601a5b7f4b1aaae8990ca7c (diff) | |
download | gpsd-79991ff14b9e396e319e108d7615d379163347d9.tar.gz |
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).
Diffstat (limited to 'test_maidenhead.py')
-rwxr-xr-x | test_maidenhead.py | 4 |
1 files changed, 3 insertions, 1 deletions
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 |