Skip to content
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

tests/test.py: Make script compatible with python3 #2611

Merged
merged 1 commit into from
Jan 31, 2020

Conversation

hosiet
Copy link

@hosiet hosiet commented Jan 31, 2020

Currently the test script assumes the returned web page is always encoded in UTF-8, which might not be the case. It is likely that the real encoding is ISO-8859-1 and that running the script under python3 will raise error:

< 
{ [11931 bytes data]
100 11923    0 11923    0     0   184k      0 --:--:-- --:--:-- --:--:--  187k
Traceback (most recent call last):
  File "tests/test.py", line 106, in <module>
    line = str(line, 'utf8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa0 in position 1105: invalid start byte

This pull request makes no assumption on the returned data and send the raw output to stderr as bytes. This should allow the test script to finish successfully when tests/test.py is run by python3.

Currently the test script assumes the returned web page is always encoded in UTF-8, which might not be the case. It is likely that the real encoding is `ISO-8859-1` and that running the script under python3 will raise error:

```
< 
{ [11931 bytes data]
100 11923    0 11923    0     0   184k      0 --:--:-- --:--:-- --:--:--  187k
Traceback (most recent call last):
  File "tests/test.py", line 106, in <module>
    line = str(line, 'utf8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa0 in position 1105: invalid start byte
```
This pull request makes no assumption on the returned data and send the raw output to stderr as `bytes`. This should allow the test script to finish successfully when `tests/test.py` is run by python3.
@madeye madeye merged commit a0ef1a5 into shadowsocks:master Jan 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants