Since the default system encoding of my Win7 x64(simplified Chinese) is not utf-8, but GBK; sort.py doesn't work in Python 3.4.2.
The traceback message is:
Traceback (most recent call last):
File "E:\GitHub\sort.py", line 52, in
main()
File "E:\GitHub\sort.py", line 22, in main
read_me = read_me_file.readlines()
UnicodeDecodeError: 'gbk' codec can't decode byte 0x93 in position 6947: illegal multibyte sequence
So I just specify the encoding explicitly by passing the keyword argument 'encoding'. (Otherwise, Python 3.x will use the system's default encoding.)
The builtin 'open' function in Python 2.7.8 doesn't provide such a parameter, however. So I use codecs.open instead.
The modified version has already been tested on Win7 x64 with both Python 2.7.8 and Python 3.4.2.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
## 📋 Pull Request Information
**Original PR:** https://github.com/vinta/awesome-python/pull/280
**Author:** [@myd7349](https://github.com/myd7349)
**Created:** 12/9/2014
**Status:** ❌ Closed
**Base:** `master` ← **Head:** `master`
---
### 📝 Commits (1)
- [`0ce698c`](https://github.com/vinta/awesome-python/commit/0ce698cc50bdfd2d544ae39f1eb92fbb7d514ae8) Specify encoding explicitly
### 📊 Changes
**1 file changed** (+7 additions, -2 deletions)
<details>
<summary>View changed files</summary>
📝 `sort.py` (+7 -2)
</details>
### 📄 Description
Since the default system encoding of my Win7 x64(simplified Chinese) is not utf-8, but GBK; sort.py doesn't work in Python 3.4.2.
The traceback message is:
> Traceback (most recent call last):
> File "E:\GitHub\sort.py", line 52, in <module>
> main()
> File "E:\GitHub\sort.py", line 22, in main
> read_me = read_me_file.readlines()
> UnicodeDecodeError: 'gbk' codec can't decode byte 0x93 in position 6947: illegal multibyte sequence
So I just specify the encoding explicitly by passing the keyword argument 'encoding'. (Otherwise, Python 3.x will use the system's default encoding.)
The builtin 'open' function in Python 2.7.8 doesn't provide such a parameter, however. So I use codecs.open instead.
The modified version has already been tested on Win7 x64 with both Python 2.7.8 and Python 3.4.2.
---
<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/vinta/awesome-python/pull/280
Author: @myd7349
Created: 12/9/2014
Status: ❌ Closed
Base:
master← Head:master📝 Commits (1)
0ce698cSpecify encoding explicitly📊 Changes
1 file changed (+7 additions, -2 deletions)
View changed files
📝
sort.py(+7 -2)📄 Description
Since the default system encoding of my Win7 x64(simplified Chinese) is not utf-8, but GBK; sort.py doesn't work in Python 3.4.2.
The traceback message is:
So I just specify the encoding explicitly by passing the keyword argument 'encoding'. (Otherwise, Python 3.x will use the system's default encoding.)
The builtin 'open' function in Python 2.7.8 doesn't provide such a parameter, however. So I use codecs.open instead.
The modified version has already been tested on Win7 x64 with both Python 2.7.8 and Python 3.4.2.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.