-
-
Notifications
You must be signed in to change notification settings - Fork 954
-
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
Beta Was this translation helpful? Give feedback.
All reactions
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
-
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.
Beta Was this translation helpful? Give feedback.
All reactions
-
Screen Shot 2021年11月05日 at 3 07 48 PM
What about setting the IO encoding?
Beta Was this translation helpful? Give feedback.
All reactions
-
I had tried other function.
image
Got another failed
Cmd('git') failed due to: exit code(1)
cmdline: git pull -v Develop
Beta Was this translation helpful? Give feedback.
All reactions
-
All are utf-8
image
Beta Was this translation helpful? Give feedback.
All reactions
-
I tried repo.git.pull() and without any parameters,it was wroking.
image
Beta Was this translation helpful? Give feedback.
All reactions
-
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?
Beta Was this translation helpful? Give feedback.
All reactions
-
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.
Beta Was this translation helpful? Give feedback.