PySvn icon indicating copy to clipboard operation
PySvn copied to clipboard

function log_default throw an UnicodeDecodeError on Windows(Chinese)

Open BobXGY opened this issue 3 years ago • 3 comments

Windows console default encoding is gbk. Function log_default can not specific an encoding type. once I call svn_remote.log_default() to get a svn repo's log with encoding utf8, there will be an error.

Traceback (most recent call last):
  File "D:/Proj/Python/myscript/module_svn.py", line 15, in <module>
    main()
  File "D:/Proj/Python/myscript/module_svn.py", line 10, in main
    print(next(svn_remote.log_default()))
  File "D:\Software\Python37\lib\site-packages\svn\common.py", line 251, in log_default
    do_combine=True)
  File "D:\Software\Python37\lib\site-packages\svn\common.py", line 60, in run_command
    return self.external_command(cmd, environment=self.__env, **kwargs)
  File "D:\Software\Python37\lib\site-packages\svn\common_base.py", line 29, in external_command
    universal_newlines=decode_text)
  File "D:\Software\Python37\lib\subprocess.py", line 376, in check_output
    **kwargs).stdout
  File "D:\Software\Python37\lib\subprocess.py", line 455, in run
    stdout, stderr = process.communicate(input, timeout=timeout)
  File "D:\Software\Python37\lib\subprocess.py", line 907, in communicate
    stdout = self.stdout.read()
UnicodeDecodeError: 'gbk' codec can't decode byte 0xae in position 170: illegal multibyte sequence

Process finished with exit code 1

BobXGY avatar Mar 03 '21 07:03 BobXGY

I add an argument to function external_command, class CommonBase, in common_base.py, this problem has been solved. can author do some optimization?

BobXGY avatar Mar 03 '21 07:03 BobXGY

I add an argument to function external_command, class CommonBase, in common_base.py, this problem has been solved. can author do some optimization?

hi,could you share your scripts? I've faced the same problem.

frozenzj avatar Mar 25 '22 05:03 frozenzj

I add an argument to function external_command, class CommonBase, in common_base.py, this problem has been solved. can author do some optimization?

hi,could you share your scripts? I've faced the same problem.

I solved it when add an argument encoding="utf-8" to subprocess.check_output in function external_command in common_base.py.

I used python 3.10.5 on window10

HamSeokHeon avatar Aug 01 '22 13:08 HamSeokHeon