M-o-a-T / owslave

Master code for slave devices
GNU General Public License v3.0
18 stars 7 forks source link

world.cfg has UTF-8 Encoded Characters causing compile errors #11

Open gpratt3151 opened 8 years ago

gpratt3151 commented 8 years ago

First of all, thank you for the project!

It looks like the file was opened in an editor that converted '...' and 'uf' to UTF-8 (like MS Word does with auto correct).

Here's the diff. I also attached a fixed version of world.cfg.

world.cfg.txt

gpratt@core ~/owslave$ diff world.cfg world.cfg.fixed
151c151
<       - 0…7: Analog input pin to read

---
>       - 0...7: Analog input pin to read
417c417
<         R-C network (10 µF @ 1 MOhm)

---
>         R-C network (10 uF @ 1 MOhm)
486c486
<         R-C network (10 µF @ 1 MOhm)

---
>         R-C network (10 uF @ 1 MOhm)

Here is the error: Traceback (most recent call last): File "./cfg", line 498, in main(*sys.argv[1:]) File "./cfg", line 67, in main s = Cfg(cfg_name) File "/home/gpratt/owslave/Cfg.py", line 64, in init self.data = yaml.load(fd) File "/usr/lib/python3/dist-packages/yaml/init.py", line 70, in load loader = Loader(stream) File "/usr/lib/python3/dist-packages/yaml/loader.py", line 34, in init Reader.init(self, stream) File "/usr/lib/python3/dist-packages/yaml/reader.py", line 85, in init self.determine_encoding() File "/usr/lib/python3/dist-packages/yaml/reader.py", line 124, in determine_encoding self.update_raw() File "/usr/lib/python3/dist-packages/yaml/reader.py", line 178, in update_raw data = self.stream.read(size) 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 0xe2 in position 5525: ordinal not in range(128)

Hope this helps.

-Greg

smurfix commented 8 years ago

On 22.08.2016 02:40, gpratt3151 wrote:

It looks like the file was opened in an editor that converted '...' and 'uf' to UTF-8 (like MS Word does with auto correct).

That was me. I happen to like UTF-8. :-P

This patch should work instead:

diff --git a/Cfg.py b/Cfg.py index 3883427..2927a3c 100644 --- a/Cfg.py +++ b/Cfg.py @@ -60,7 +60,7 @@ class Cfg(object): iseq = 1

 def __init__(self, f):

Alternately you could "export LC_ALL=en_US.UTF-8" in the shell. That'd magically make your Python3 work with all UTF-8 files, not just mine.

-- Matthias Urlichs

gpratt3151 commented 8 years ago

Ok. Perhaps we should put that in the README.md or HOWTO.md file? It took me a few hours to figure it out as this appears to be a very common python3 issue and doesn't throw a very good error pointing to the file in error. And, even if it did reference the file, trying to figure out a character position can be difficult. Do you prefer pull requests?

smurfix commented 8 years ago

Pull requests are good.

gpratt3151 commented 8 years ago

Ok. I'll probably have some time to work on it this weekend and I'll shoot you a pull request on the documentation if I see anything. Appreciate the quick response.