-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Fix encoding problems (Windows, python >= 3) #1469
Conversation
@@ -189,32 +191,32 @@ def test_saveAsText(self): | |||
d = Dictionary(small_text) | |||
|
|||
d.save_as_text(tmpf) | |||
with open(tmpf) as file: | |||
with codecs.open(tmpf, 'r', encoding='utf-8') as file: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-1: please use smart_open
, binary mode rb
, and convert to unicode explicitly (avoid codecs
).
|
||
d.save_as_text(tmpf, sort_by_word=False) | ||
with open(tmpf) as file: | ||
with codecs.open(tmpf, 'r', encoding='utf-8') as file: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-1: please use smart_open
, binary mode rb
, and convert to unicode explicitly (avoid codecs
).
no_num_docs_serialization = "1\tprvé\t1\n2\tslovo\t2\n" | ||
with open(tmpf, "w") as file: | ||
no_num_docs_serialization = to_utf8("1\tprvé\t1\n2\tslovo\t2\n") | ||
with open(tmpf, "wb") as file: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer smart_open
.
no_num_docs_serialization = "2\n1\tprvé\t1\n2\tslovo\t2\n" | ||
with open(tmpf, "w") as file: | ||
no_num_docs_serialization = to_utf8("2\n1\tprvé\t1\n2\tslovo\t2\n") | ||
with open(tmpf, "wb") as file: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer smart_open
.
Second part of #1441