Fix encoding issue #3

Merged
merged 1 commit into from May 24, 2016

Conversation

Projects
None yet
3 participants
Contributor

dholbach commented Apr 28, 2016

Traceback:
File "./generate", line 31, in
main()
File "/tmp/tmpoWBMbu/snappy-dev-website/sitegenerator/init.py",
line 68, in main
devices = load_device_metadata(release)
File "/tmp/tmpoWBMbu/snappy-dev-website/sitegenerator/releases.py",
line 79, in load_device_metadata
devices_metadata = yaml.load(f.read())
File "/usr/lib/python3.4/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position
2299: ordinal not in range(128)

sitegenerator/releases.py
@@ -75,7 +76,8 @@ def load_device_metadata(release):
'RELEAS_VERSION': '16.04' },
}"""
devices_metadata = {}
- with open(os.path.join(ROOT_DIR, DEVICES_MAPPING)) as f:
+ with codecs.open(os.path.join(ROOT_DIR, DEVICES_MAPPING),
+ encoding='utf-8') as f:
@sergiusens

sergiusens Apr 28, 2016

Curious to know why use codecs and not just open passing in the encoding.

@dholbach

dholbach Apr 28, 2016

Contributor

Oh... I was used to that from python2. Let me go change it.

Looks good, just have a question

Traceback (most recent call last):
  File "./generate", line 31, in <module>
    main()
  File "/tmp/tmpoWBMbu/snappy-dev-website/sitegenerator/__init__.py",
line 68, in main
    devices = load_device_metadata(release)
  File "/tmp/tmpoWBMbu/snappy-dev-website/sitegenerator/releases.py",
line 79, in load_device_metadata
    devices_metadata = yaml.load(f.read())
  File "/usr/lib/python3.4/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position
2299: ordinal not in range(128)

@didrocks didrocks merged commit c6ca568 into ubuntu-core:master May 24, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment