8000 fix: Error decoding command output on Windows by zhiweio · Pull Request #11 · timerring/bilitool · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: Error decoding command output on Windows #11

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

Merged
merged 1 commit into from
Jan 12, 2025

Conversation

zhiweio
Copy link
Contributor
@zhiweio zhiweio commented Jan 11, 2025

Description

This PR resolves a UnicodeDecodeError that occurs on Windows systems when decoding command output. The issue arises due to the default encoding (gbk) being unable to handle certain byte sequences, as shown in the error traceback:

Traceback (most recent call last):
  File "C:\Users\wangz\.conda\envs\llm\Lib\threading.py", line 1045, in _bootstrap_inner
    self.run()
  File "C:\Users\wangz\.conda\envs\llm\Lib\threading.py", line 982, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\wangz\.conda\envs\llm\Lib\subprocess.py", line 1599, in _readerthread
    buffer.append(fh.read())
                  ^^^^^^^^^
UnicodeDecodeError: 'gbk' codec can't decode byte 0xaa in position 39: illegal multibyte sequence

Additionally, the error propagates to cause a TypeError when attempting to parse None as JSON:

Traceback (most recent call last):
  File "C:\Users\wangz\Projects\github\ytbili\biliup\__init__.py", line 273, in <module>
    bup.login()
  File "C:\Users\wangz\Projects\github\ytbili\biliup\__init__.py", line 212, in login
    login_bili(export_cookie)
  File "C:\Users\wangz\.conda\envs\llm\Lib\site-packages\biliupload\login\login_bili.py", line 83, in login_bili
    verify_login(auth_code, export)
  File "C:\Users\wangz\.conda\envs\llm\Lib\site-packages\biliupload\login\login_bili.py", line 58, in verify_login
    body = execute_curl_command(api, data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\wangz\.conda\envs\llm\Lib\site-packages\biliupload\login\login_bili.py", line 32, in execute_curl_command
    return json.loads(result.stdout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\wangz\.conda\envs\llm\Lib\json\__init__.py", line 339, in loads
    raise TypeError(f'the JSON object must be str, bytes or bytearray, '
TypeError: the JSON object must be str, bytes or bytearray, not NoneType

This fix ensures proper handling of command output encoding to prevent such errors.

Copy link
Owner
@timerring timerring left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for the correction.

@timerring timerring added good first issue Good for newcomers fix labels Jan 12, 2025
@timerring timerring merged commit 3eb3cbe into timerring:main Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix good first issue Good for newcomers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0