flying-circus / pyfilesystem

Automatically exported from code.google.com/p/pyfilesystem
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Python3 error with file encodings #181

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. import fs.ftpfs
2. pfs = fs.opener.fsopendir('zip:ftp://host/path/item.zip')
3.pfs.printtree()

What is the expected output? What do you see instead?
Print zip tree, instead get:
  File "/Users/amohr/dev/drmtools/python/scripts/support/p4python/build.py", line 36, in get_openssl_dir
    pfs.printtree()
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/fs/base.py", line 1369, in printtree
    print_fs(self, max_levels=max_levels)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/fs/utils.py", line 577, in print_fs
    print_dir(fs, path)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/fs/utils.py", line 566, in print_dir
    write('%s %s' % (wrap_prefix(prefix + char_line), wrap_dirname(item)))
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/fs/utils.py", line 495, in write
    file_out.write(line.encode(file_encoding, 'replace') + b'\n')
TypeError: must be str, not bytes

What version of the product are you using? On what operating system?
0.5.0, python 3.4.1 on OSX 10.9

Please provide any additional information below.
issue is that its trying to write to stdout and it needs to be a string, and 
not a byte array.

Original issue reported on code.google.com by thehes...@gmail.com on 14 Jul 2014 at 7:45

GoogleCodeExporter commented 9 years ago
whoops: 1: import fs.opener

Original comment by thehes...@gmail.com on 14 Jul 2014 at 7:53

GoogleCodeExporter commented 9 years ago
btw another issue you'll note doing this is that the ftplib._encode method is 
encoding to a byte array when it should not be as well.

Original comment by thehes...@gmail.com on 14 Jul 2014 at 8:01