GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — I have a decode issue with GitPython · gitpython-developers/GitPython · Discussion #1374

I have a decode issue with GitPython #1374

Answered by Byron
99848873 asked this question in Q&A
I have a decode issue with GitPython #1374
@99848873 99848873
Nov 5, 2021 · 2 comments · 8 replies
Answered by Byron Return to top
Discussion options
  • Uh oh!

    There was an error while loading. Please reload this page.

  • Uh oh!

    There was an error while loading. Please reload this page.

99848873
Nov 5, 2021

My code is ,

image

And there is no chinese in my repo path。

And an exception was found.

Exception in thread Thread-22:
Traceback (most recent call last):
  File "C:\zhoujinyuWorkSpace\MyUe4\pyscript\venv\lib\site-packages\git\cmd.py", line 106, in pump_stream
    for line in stream:
UnicodeDecodeError: 'gbk' codec can't decode byte 0xa8 in position 1297: illegal multibyte sequence

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "c:\python38\lib\threading.py", line 932, in _bootstrap_inner
    self.run()
  File "c:\python38\lib\threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "C:\zhoujinyuWorkSpace\MyUe4\pyscript\venv\lib\site-packages\git\cmd.py", line 119, in pump_stream
    raise CommandError([f'<{name}-pump>'] + remove_password_if_present(cmdline), ex) from ex
git.exc.CommandError: Cmd('<stderr-pump>') failed due to: UnicodeDecodeError(''gbk' codec can't decode byte 0xa8 in position 1297: illegal multibyte sequence')
  cmdline: <stderr-pump> git pull -v origin
Update C:/workspace/AClient_Bin/AClient/Content/ repo
You must be logged in to vote
All reactions
Answered by Byron Nov 5, 2021

Strangely enough it looks like I have seen this before.

The problem seems to be that the python interpreter default code is gbk, but should be utf-8 for most purposes. It can be changed on startup I think.

It looks like this is how you change the default encoding.

View full answer

Replies: 2 comments · 8 replies

Comment options
  • Uh oh!

    There was an error while loading. Please reload this page.

Byron
Nov 5, 2021
Maintainer

Strangely enough it looks like I have seen this before.

The problem seems to be that the python interpreter default code is gbk, but should be utf-8 for most purposes. It can be changed on startup I think.

It looks like this is how you change the default encoding.

You must be logged in to vote
All reactions
8 replies
@Byron
Comment options
  • Uh oh!

    There was an error while loading. Please reload this page.

Byron Nov 5, 2021
Maintainer

Screen Shot 2021-11-05 at 3 07 48 PM

What about setting the IO encoding?

All reactions
@99848873
Comment options
  • Uh oh!

    There was an error while loading. Please reload this page.

99848873 Nov 5, 2021
Author

I had tried other function.
image
Got another failed
Cmd('git') failed due to: exit code(1)
cmdline: git pull -v Develop

All reactions
@99848873
Comment options
  • Uh oh!

    There was an error while loading. Please reload this page.

99848873 Nov 5, 2021
Author

All are utf-8
image

All reactions
@99848873
Comment options
  • Uh oh!

    There was an error while loading. Please reload this page.

99848873 Nov 5, 2021
Author

I tried repo.git.pull() and without any parameters,it was wroking.
image

All reactions
@Byron
Comment options
  • Uh oh!

    There was an error while loading. Please reload this page.

Byron Nov 6, 2021
Maintainer

Where is the 'gbk' codec coming from? Is it some other program code outside of GitPython that sets it? What are these values after executing the code running GitPython?

All reactions
Answer selected by Byron
Comment options
  • Uh oh!

    There was an error while loading. Please reload this page.

  • Uh oh!

    There was an error while loading. Please reload this page.

EliahKagan
Dec 22, 2023
Collaborator

Some further information: On Windows gbk refers to code page 936, and it is the default ANSI active code page on Windows in some locales, especially where Chinese is spoken. Where English is spoken, code page 1252 is most often the default in Windows.

Python can be made to use UTF-8 instead of the ANSI active code page by running the interpreter with -X utf8 or setting the PYTHONUTF8 environment variable to the value 1. I have found that this (the -X way) has been sufficient to overcome some limitations, such as #1747 before it was fixed. I am unsure if it is sufficient to overcome all such limitations; I have not at this point tested to see if it ameliorates #1362.

Python will also use UTF-8 when instructed to do so, by passing encoding="utf-8" where applicable, which is something that has to be done in the code of a program. If running Python with -X utf8 is sufficient to work around most or all encoding limitations in GitPython, then it might be possible to fix them by using encoding="utf-8" in most or all calls to functions that recognize it (when operating with text). But I am unsure if that would work, because there is also the behavior of external programs, particularly GitPython's git subprocesses, to consider.

Unlike other systems where the most closely related locale settings are more readily changed and can be changed easily for specific commands using simple and well-documented techniques, the ANSI active code page on a Windows system is a system-level setting (unlike the interface language setting and preferred language settings), which can be changed, but only for the whole system, and this is rarely done. This post and its linked sources provide some more information about that. Windows can also be made to use UTF-8 where it would otherwise use a localized code page, though this is considered "beta" and some applications might have problems.

You must be logged in to vote
All reactions
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
3 participants
@99848873 @Byron @EliahKagan
Converted from issue

This discussion was converted from issue #1373 on November 05, 2021 06:51.

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.