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
Read/write text as string and plist as bytes, add tests #23
Conversation
f = open(path, "rb") | ||
text = f.read() | ||
f.close() | ||
with open(path, "r") as f: |
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.
you should specify the encoding="utf-8" here, otherwise io.open will default to the preferred locale encoding, which on windows is not utf-8.
thank you Denis! This looks much better than my hotfix 👍 can you remind me why we can't read/write plist files as unicode strings and we need to use bytes? |
def test_subpathWriteFile(self): | ||
expected_text = 'foo bar™' | ||
subpathWriteFile(expected_text, self.directory, self.filename) | ||
with open(self.filepath, 'r') as f: |
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.
if instead of trademark symbol here you had used a character which can't be encoded in cp1252, I would expect this test to fail on Windows.
Why are we not testing Windows with appveyor?
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.
Good point! I’ll add encoding="utf-8" to open()
in subpathReadFile()
and subpathWriteFile()
and in the tests.
Appveyor needs to be enabled for the project. We can open an issue about that to ask @typesupply to do that.
Use loads and dumps for Plist
Read/write text as string and plist as bytes, add tests
💯 |
This fixes #19 and adds some minor changes.
subpathReadPlist()
andsubpathWritePlist()
don't usesubpathReadFile()
andsubpathWriteFile()
anymore.unicode_literals
._readPlistFromBytes()
and_writePlistToBytes()
as_loads()
and_dumps()
.