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
Nov 5, 2021
·
2 comments
·
8 replies
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.
|
My code is ,

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
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.
Replies:
2 comments
·
8 replies
Comment options
-
Uh oh!
There was an error while loading. Please reload this page.
|
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
8 replies
Comment options
-
Uh oh!
There was an error while loading. Please reload this page.
|

What about setting the IO encoding?
|
Comment options
-
Uh oh!
There was an error while loading. Please reload this page.
|
I had tried other function.

Got another failed
Cmd('git') failed due to: exit code(1)
cmdline: git pull -v Develop
|
Comment options
-
Uh oh!
There was an error while loading. Please reload this page.
|
All are utf-8

|
Comment options
-
Uh oh!
There was an error while loading. Please reload this page.
|
I tried repo.git.pull() and without any parameters,it was wroking.

|
Comment options
-
Uh oh!
There was an error while loading. Please reload this page.
|
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?
|
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.
|
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
0 replies
Converted from issue
This discussion was converted from issue #1373 on November 05, 2021 06:51.
|