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 #2533

Open
logica-umeno opened this issue Dec 3, 2024 · 0 comments
Open

UnicodeDecodeError #2533

logica-umeno opened this issue Dec 3, 2024 · 0 comments

Comments

@logica-umeno
Copy link

What were you trying to do?

Running code with Japanese comments in PygameZero mode

What steps did you take to trigger the issue?

For Japanese children, understanding source code in English is very difficult. Therefore, I teach them to write explanations of the source code in Japanese.

  • I chose PygameZero Mode.

  • I wrote the following code

# エイリアンを作成する
alien = Actor('alien')
  • I pressed the Play button.

What did you expect to happen?

UnicodeDecodeError occurred.

What actually happened?

UnicodeDecodeError

pygame 2.1.2 (SDL 2.0.18, Python 3.8.12)
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
  File "C:\Users\umeno\AppData\Local\Programs\MUEDIT~1\Python\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\umeno\AppData\Local\Programs\MUEDIT~1\Python\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\umeno\AppData\Local\python\mu\mu_venv-38-20241126-182034\lib\site-packages\pgzero\__main__.py", line 3, in <module>
    main()
  File "C:\Users\umeno\AppData\Local\python\mu\mu_venv-38-20241126-182034\lib\site-packages\pgzero\runner.py", line 77, in main
    src = f.read()
UnicodeDecodeError: 'cp932' codec can't decode byte 0x88 in position 24: illegal multibyte sequence


---------- FINISHED ----------
exit code: 1 status: 0

Operating System Version

Windows10

Mu Version

1.2.0

Other Info

It seems that Python is mistakenly recognizing the code as being written in cp932.
Therefore, if you write the following at the beginning of the source code, it will work correctly.

# coding: cp932

image

However, if the checking function is used on code with cp932 specified as the character encoding, MU-Editor crashes.
image

Traceback (most recent call last):
  File "C:\Users\umeno\AppData\Local\Programs\Mu Editor\Python\lib\site-packages\mu\logic.py", line 1347, in check_code
    flake = check_flake(filename, tab.text(), builtins)
  File "C:\Users\umeno\AppData\Local\Programs\Mu Editor\Python\lib\site-packages\mu\logic.py", line 387, in check_flake
    check(code, filename, reporter)
  File "C:\Users\umeno\AppData\Local\Programs\Mu Editor\Python\lib\site-packages\pyflakes\api.py", line 47, in check
    file_tokens = checker.make_tokens(codeString)
  File "C:\Users\umeno\AppData\Local\Programs\Mu Editor\Python\lib\site-packages\pyflakes\checker.py", line 750, in make_tokens
    return tuple(tokenize.tokenize(lambda: next(lines, b'')))
  File "C:\Users\umeno\AppData\Local\Programs\Mu Editor\Python\lib\tokenize.py", line 455, in _tokenize
    line = line.decode(encoding)
UnicodeDecodeError: 'cp932' codec can't decode byte 0x88 in position 24: illegal multibyte sequence

I hope that Japanese comments can be written in PygameZero, and that the checking function works correctly.

Editor Log

Sorry , I cannot paste the log file because it contains personal information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant