summaryrefslogtreecommitdiff
path: root/tools/validate-yaml.py
diff options
context:
space:
mode:
authorScott Moser <smoser@brickies.net>2016-12-02 20:20:41 -0500
committerScott Moser <smoser@brickies.net>2016-12-02 20:20:41 -0500
commit166df605dc9864eb163007300db7a611feb309d6 (patch)
tree7b87cd0b092f731c610cc59c3f18fa8b7c200ed5 /tools/validate-yaml.py
parentf6d5dc486776019e0799f95f8d1982be8fba4da5 (diff)
downloadvyos-cloud-init-166df605dc9864eb163007300db7a611feb309d6.tar.gz
vyos-cloud-init-166df605dc9864eb163007300db7a611feb309d6.zip
fix decoding of utf-8 chars in yaml test
Python 3 would fail to load yaml from doc/examples/cloud-config-apt.txt when the LANG (specifically LC_CTYPE) was 'C'. The changes here do 2 things: a.) remove the non-ascii characters from the yaml file. b.) fix the validate-yaml.py program to decode using utf-8 specifically rather than using the inherited settings. This fixes it now for ascii and in the future also should non-ascii slip in.
Diffstat (limited to 'tools/validate-yaml.py')
-rwxr-xr-xtools/validate-yaml.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/validate-yaml.py b/tools/validate-yaml.py
index ed9037d9..2f28d230 100755
--- a/tools/validate-yaml.py
+++ b/tools/validate-yaml.py
@@ -12,8 +12,8 @@ if __name__ == "__main__":
for fn in sys.argv[1:]:
sys.stdout.write("%s" % (fn))
try:
- fh = open(fn, 'r')
- yaml.safe_load(fh.read())
+ fh = open(fn, 'rb')
+ yaml.safe_load(fh.read().decode('utf-8'))
fh.close()
sys.stdout.write(" - ok\n")
except Exception as e: