mainsail-crew / mainsail-config

Mainsail klipper macros and settings
GNU General Public License v3.0
68 stars 22 forks source link

mainsail.cfg unicode symbol issue #32

Open UserDmitry opened 5 months ago

UserDmitry commented 5 months ago

Klipper report an issue "Unable to open *path*\mainsail.cfg file". In klippy.log there is a error: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 7558: ordinal not in range(128) Config error Traceback (most recent call last): File "/home/sapphire/klipper/klippy/configfile.py", line 159, in _read_config_file data = f.read() File "/home/sapphire/klippy-env/lib/python3.6/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 7558: ordinal not in range(128)

This byte appears at str. number 137: # we need to use the unicode (\u00B0) for the ° as py2 env's would throw an error otherwise

Unicode symbol in this comment " ° " cause this error.

pedrolamas commented 5 months ago

I've tried to reproduce this issue on a Docker container running Python 2.7.18 and it worked fine...

@UserDmitry can you please upload a full klippy.log so we can check the issue directly?

UserDmitry commented 5 months ago

Yes, of course. klippy.log

pedrolamas commented 5 months ago

Looking at the log I can see Klipper is using python 3.6.9, so that might be the problem as AFAIK, unicode support was added in 3.9.

Nevertheless, I do think we should fix this issue here as it is such a trivial fix.

@zellneralex any comments on this?

zellneralex commented 5 months ago

I really love it, I am only adding that comment so that people understand the cryptic Unicode usage here. I will change the comment in the next days.

Currently I am on a business trip.