Skip to content
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 on windows #158

Closed
MatteoPiovanelli opened this issue Apr 2, 2022 · 8 comments
Closed

UnicodeDecodeError on windows #158

MatteoPiovanelli opened this issue Apr 2, 2022 · 8 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@MatteoPiovanelli
Copy link

Just installed the toolkit with pip3 install 'gdtoolkit==3.*'
Launched gdformat --diff . in the project folder.
I get this output in my terminal:

Traceback (most recent call last):
  File "C:\Program Files\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\admin\AppData\Roaming\Python\Python310\Scripts\gdformat.exe\__main__.py", line 7, in <module>
  File "C:\Users\admin\AppData\Roaming\Python\Python310\site-packages\gdtoolkit\formatter\__main__.py", line 69, in main
    _check_files_formatting(files, line_length, arguments["--diff"], safety_checks)
  File "C:\Users\admin\AppData\Roaming\Python\Python310\site-packages\gdtoolkit\formatter\__main__.py", line 90, in _check_files_formatting
    code = fh.read()
  File "C:\Program Files\Python310\lib\encodings\cp1252.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 558: character maps to <undefined>

Searching online lead me to https://stackoverflow.com/a/49562606

My guess would be that explicitly setting the encoding to use when opening the file in

with open(file_path, "r") as fh:
would fix this, but I'm not sure about all the possible implications this may have. I think Godot by default saves encode files as UTF8, but I'm not sure.

@Scony Scony added the bug Something isn't working label Apr 2, 2022
@Scony
Copy link
Owner

Scony commented Apr 2, 2022

@MatteoPiovanelli-Laser would you be able to share the file/part of the file which fails?

@MatteoPiovanelli
Copy link
Author

Here's a link to it (from the repo I forked it from)
https://github.com/Orama-Interactive/Pixelorama/blob/master/src/Preferences/HandleLanguages.gd

@Scony Scony added the help wanted Extra attention is needed label Apr 23, 2022
@Scony Scony added this to the 3.x milestone Sep 17, 2022
@Scony Scony added this to Roadmap Feb 7, 2023
@Scony Scony removed this from the 3.x milestone Feb 7, 2023
@HolonProduction
Copy link
Contributor

Starting from 72f9faf all files are loaded with utf-8 encoding. The file will load without problems on the master branch. So basically this commit needs to be backported or cherrypicked or watever advanced git magic exists for this.

Scony added a commit that referenced this issue Feb 8, 2023
@Scony
Copy link
Owner

Scony commented Feb 8, 2023

Fixed by 4292c4a, to be released in 3.5

@Scony Scony closed this as completed Feb 8, 2023
@github-project-automation github-project-automation bot moved this to Done in Roadmap Feb 8, 2023
@Scony Scony removed this from Roadmap Feb 8, 2023
@HolonProduction
Copy link
Contributor

I have not looked into it but #149 and #167 seem to be encoding related as well. Maybe they are obsolete as well.

@Prikalel
Copy link

and where is 3.5 release? only 3.4.0 and 4.0.0 are available 🤔

@Scony
Copy link
Owner

Scony commented Mar 15, 2023

@Prikalel released today - I was planning to add more features, but I de-scoped that release.

@Cammymoop
Copy link
Contributor

Just checked and both #167 and #149 are indeed fixed when running through the command line. As of the change in code_formatter.py in 5f0da8f it also works in VSCode (would be nice to have a version bump for this)

Scony added a commit that referenced this issue Oct 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants