-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 #21
Comments
Hi, could you please add option -y to the optimizer command line and paste the whole traceback?
Also, please specify:
- Your Python version (/usr/bin/python --version)
- Your operating system
- Output of 'locale'
- The encoding of your script
And if you can, please try run-tests.py and let me know if there are any errors.
|
Sure thing macOS Mojave 10.14.6
LANG="de_DE.UTF-8" What do you mean with "encoding of your script"? |
Thanks for the info. Those encoding problems are starting to be a real PITA, so much so that I'm considering going full Python 3.x instead of polyglot 2.x/3.x. The problem is happening in the output module; I wasn't expecting that as a cause of problems.
By encoding I mean https://en.wikipedia.org/wiki/Character_encoding - the more sophisticated editors usually let you specify which encoding to use when saving the file, or let you choose it while editing. I don't know VScode so I can't tell you where to find it, but a google search suggests that the encoding is specified in the bottom bar. If it says "UTF-8" there, then it's fine. Your system is configured as UTF-8 according to the output of locale, so it's likely that the editor is using it too.
The problem has to do with a non-ASCII character most likely. Are you using non-ASCII somewhere in your program? Do you think you can remove lines from your program until you find a minimal script that reproduces the problem, and post it?
|
Yes, it's UTF-8. And indeed I am using (few) non-ASCII char's. There are passages like this:
and passages like this:
I can try to comb through them, and see what happens. |
Unfortunately, that didn't solved the problem. I replaced every non-ascii character with llChar(xxxx) and ran the code through https://pages.cs.wisc.edu/~markm/ascii.html to find any non-ascii left over. The code is clean, the error message the same:
|
llChar is not going to help, because it's evaluated and replaced with a string containing the character that causes problems before the output phase, so it doesn't change anything.
What I'm asking you is if you can create a minimal test case, something that you're comfortable with sharing and helps me reproduce the issue. You can trim parts of your script and replace others until you get something you can share that still causes problems, that I can look into.
It would also help if you can run the run-tests.py program provided with the optimizer and report any problems you find.
|
oh, okay - well, since we assume it's the non-ASCII characters, a test case might be easy to put together |
OK, this is the maximum stripped down that still fails:
|
That test case has been very valuable because it allowed me to reproduce the issue. I've managed to further reduce it to this minimal script: https://github.com/Sei-Lisa/LSL-PyOptimizer/blob/master/unit_tests/regression.suite/issue-21.lsl
Fixed in master. Please test if it works with your complete script and please report any further problems you run into, if any.
Thanks a lot for your help!
|
Yep, the new version works without any error message, and produces the expected output. Thank you very much! For laymen: What was the issue? |
nvm, found the commit and the explanation |
Hi there,
on one script I tried to optimize, I get these kind of errors (one per each attempt, the numbers seem to be arbitrarily changing, the 2912 shows up often though):
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 4295: ordinal not in range(128)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 200: ordinal not in range(128)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 2912: ordinal not in range(128)
I tested my build process with a different script, and it ran fine, so I assume it's something in my current script the optimizer stumbles across.
My current build process:
VSCode Build Task macro:
The text was updated successfully, but these errors were encountered: