Open GoogleCodeExporter opened 8 years ago
Seems to work for me. Maybe it was fixed since you forked.
>>> from fs.memoryfs import *
>>> m=MemoryFS()
>>> f=m.open('jp.txt', 'w')
>>> f.write(u'私は学生です')
6L
>>> f.close()
>>> m.tree()
╰── jp.txt
>>> m.getcontents('jp.txt')
'\xe7\xa7\x81\xe3\x81\xaf\xe5\xad\xa6\xe7\x94\x9f\xe3\x81\xa7\xe3\x81\x99'
>>> m.getcontents('jp.txt', 'rt')
u'\u79c1\u306f\u5b66\u751f\u3067\u3059'
>>> print _
私は学生です
Can you still reproduce the error?
Original comment by willmcgugan
on 3 Sep 2013 at 1:17
I copied in the most recent version of pyfilesystem and using your script got
the same error (I moved the example script directly into a copy of the svn
read-only pyfilesystem):
# -*- coding: utf-8 -*-
from memoryfs import *
m=MemoryFS()
f=m.open('jp.txt', 'w')
x = u'私は学生です'
f.write(x)
f.close()
m.tree()
--> UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-5:
ordinal not in range(128)
Are you using a different encoding at the top of the file? I'm also on Python
2.7.3, so I'm not getting unicode literals everywhere for free.
Original comment by abishopr...@box.com
on 6 Sep 2013 at 3:30
That works fine for me. Only difference is I'm on Linux.
That won't work as a way of using the svn version though. memoryfs has a bunch
of "from fs." imports that will import the installed code. Best to run "python
setup.py develop".
Original comment by willmcgugan
on 6 Sep 2013 at 4:00
Ok, I'll keep digging on this. Thanks for helping Will.
Original comment by abishopr...@box.com
on 6 Sep 2013 at 4:05
Original issue reported on code.google.com by
abishopr...@box.com
on 10 Jul 2013 at 4:17