summaryrefslogtreecommitdiff
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
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.
-rw-r--r--SConstruct2
-rw-r--r--gpscap.py5
2 files changed, 5 insertions, 2 deletions
diff --git a/SConstruct b/SConstruct
index 40b5df41..9c7b4f0c 100644
--- a/SConstruct
+++ b/SConstruct
@@ -2074,7 +2074,7 @@ env.Command('www/hardware.html', ['gpscap.py',
'www/hardware-head.html',
'gpscap.ini',
'www/hardware-tail.html'],
- ['(cat www/hardware-head.html && $SC_PYTHON gpscap.py && cat www/hardware-tail.html) >www/hardware.html'])
+ ['(cat www/hardware-head.html && PYTHONIOENCODING=utf-8 $SC_PYTHON gpscap.py && cat www/hardware-tail.html) >www/hardware.html'])
# The diagram editor dia is required in order to edit the diagram masters
# Utility("www/cycle.svg", ["www/cycle.dia"], ["dia -e www/cycle.svg www/cycle.dia"])
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