Skip to content

AttributeError: 'ReadTarFS' object has no attribute '_tar' #333

Closed
@chfw

Description

@chfw

Hi all

I caught this hidden exception with this code while using your nice library:

from fs import tarfs

tarfs.TarFS('tar://i_do_not_exist.tar')

Above code will trigger the following ignored exception:

Exception ignored in: <function FS.__del__ at 0x108b2b950>
Traceback (most recent call last):
  File "/Users/jaska/github/moremoban/pyfilesystem2/fs/base.py", line 117, in __del__
    self.close()
  File "/Users/jaska/github/moremoban/pyfilesystem2/fs/tarfs.py", line 465, in close
    self._tar.close()
AttributeError: 'ReadTarFS' object has no attribute '_tar'

======================================================================
FAIL: test_read_non_existent_file (tests.test_tarfs.TestReadTarFS)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/jaska/github/moremoban/pyfilesystem2/fs/errors.py", line 130, in new_func
    return func(*args, **kwargs)
  File "/Users/jaska/github/moremoban/pyfilesystem2/fs/tarfs.py", line 272, in __init__
    self._tar = tarfile.open(file, mode="r")
FileNotFoundError: [Errno 2] No such file or directory: 'tar://i_do_not_exist.tar'

The same applies for ZipFS. I will send one PR over.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions