Skip to content

ZipFS (Writing Mode) Error on Windows #256

@merlink01

Description

@merlink01

Python 35 (32Bit)
Pyfilesystem: 2.2.1

Testcode:

from fs import zipfs
testfs = zipfs.ZipFS('test.zip',write=True)
testfile = testfs.open('testfile.txt','w')
testfile.write('Hello World')
testfile.close()
testfs.close()

Result: An empty ZipFile is created.

After looking in the code I saw a Try,Finally around
self.write_zip() (zipfs.py:239)

This is really bad, because here a Silent Error + Data Loss happened.

After disabling the Try Finally I got this Error:

Traceback (most recent call last):
  File "error.py", line 7, in <module>
    testfs.close()
  File "C:\Python35-32\lib\site-packages\fs\zipfs.py", line 239, in close
    self.write_zip()
  File "C:\Python35-32\lib\site-packages\fs\zipfs.py", line 271, in write_zip
    encoding=encoding or self.encoding,
  File "C:\Python35-32\lib\site-packages\fs\compress.py", line 61, in write_zip
    for path, info in gen_walk:
  File "C:\Python35-32\lib\site-packages\fs\walk.py", line 385, in info
    for _path, info in _walk:
  File "C:\Python35-32\lib\site-packages\fs\walk.py", line 405, in _walk_breadth
    for info in self._scan(fs, dir_path, namespaces=namespaces):
  File "C:\Python35-32\lib\site-packages\fs\walk.py", line 277, in _scan
    for info in fs.scandir(dir_path, namespaces=namespaces):
  File "C:\Python35-32\lib\site-packages\fs\osfs.py", line 459, in _scandir
    for dir_entry in scandir(sys_path):
TypeError: os.scandir() doesn't support bytes path on Windows, use Unicode instead

Any Idea what I can do to get a zipfile created?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions