summaryrefslogtreecommitdiff
path: root/gpscap.py
diff options
context:
space:
mode:
authorFred Wright <fw@fwright.net>2017-03-03 15:09:21 -0800
committerFred Wright <fw@fwright.net>2017-03-03 15:44:33 -0800
commitb396450d1c29148edcd9e468ca1775464151ed5b (patch)
tree237f34cf21243bbab361b332810d5bdbdb62d266 /gpscap.py
parente5a0edf9aa58475aaa59e9a238374904d713182c (diff)
downloadgpsd-b396450d1c29148edcd9e468ca1775464151ed5b.tar.gz
Fixes broken build of www/hardware.html.
Commit 8200880a (polyglot rework) broke the build of hardware.html, due to problems with default encodings in gpscap.py. This went unnoticed for nearly a year since the 'www' target is not part of the default build, and because the failure didn't propagate to an overall build failure. Since the intended encoding for both the input and output is UTF-8, this is fixed by specifying that encoding explicitly. This needs to be done in two places: 1) The invocation of the ConfigParser's read() method needs to specify the encoding of the input. This argument isn't available in Python 2.6, so there's a fallback for that case (where it's unneeded). 2) The encoding of the piped output needs to be specified. This is done by setting the PYTHONIOENCODING environment variable when running gpscap.py. TESTED: Ran "scons build-all www check". Verified that the output looks plausible in a browser, including the two umlauted characters. Also verified that running gpscap.py standalone (with PYTHONIOENCODING set) works correctly with all supported Python versions.
Diffstat (limited to 'gpscap.py')
-rw-r--r--gpscap.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/gpscap.py b/gpscap.py
index 84e8e985..51f7c6d8 100644
--- a/gpscap.py
+++ b/gpscap.py
@@ -19,7 +19,10 @@ class GPSDictionary(configparser.RawConfigParser):
configparser.RawConfigParser.__init__(self)
if not files:
files = ["gpscap.ini", "/usr/share/gpsd/gpscap.ini"]
- self.read(files)
+ try:
+ self.read(files, encoding='utf-8')
+ except TypeError:
+ self.read(files) # For Python 2.6
# Resolve uses= members
while True:
keepgoing = False