-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
tmpdir.join("foo").write(...) doesn't work as expected. #605
Comments
Original comment by Alexander Dudko (BitBucket: oktopuz, GitHub: oktopuz): If you call open() in python 2.7, the default 'ascii' codec is used. According to https://docs.python.org/2/howto/unicode.html:
The code point of u'æ' is above 127. In other words this is expected error that has nothing to do with pytest. You might want to check https://docs.python.org/2.7/library/codecs.html?highlight=open#codecs.open to work with UTF-8 encoded files. |
Original comment by Bjorn Pettersen (BitBucket: thebjorn, GitHub: thebjorn): Yes, the code point of æ is above 127, but neither of
are Unicode. They've been encoded, so they're byte strings:
Byte strings containing the full 256 possible byte values, are perfectly writable in Python:
so the question remains: how do you write a Unicode string to a file in py.test, since the normal method of encoding it to utf-8 or latin-1 does not work? |
Original comment by Bjorn Pettersen (BitBucket: thebjorn, GitHub: thebjorn): It looks like this code:
tries to decode the encoded string back to Unicode using the default encoding, and then writes the newly created Unicode string to |
Original comment by Bjorn Pettersen (BitBucket: thebjorn, GitHub: thebjorn): I'm now running py 1.4.26 and pytest 2.6.4 (I believe those are the latest..) and getting the exact same errors.
|
Original comment by Bjorn Pettersen (BitBucket: thebjorn, GitHub: thebjorn): I've also verified the problem on linux:
|
I think the question here is if |
Seems more like a (cc'ing people that were originally part of the conversation) |
I think the most useful solution is to make |
In the long term wed like to replace the py.path internals with pathlib |
closing this one as the upstream issue is pytest-dev/py#107 |
Originally reported by: Bjorn Pettersen (BitBucket: thebjorn, GitHub: thebjorn)
All of the following testcase
fails with the following errors:
The text was updated successfully, but these errors were encountered: