Skip to content
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

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

Closed
chfw opened this issue Aug 2, 2019 · 1 comment
Closed

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

chfw opened this issue Aug 2, 2019 · 1 comment
Assignees
Labels

Comments

@chfw
Copy link
Contributor

chfw commented Aug 2, 2019

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.

@chfw
Copy link
Contributor Author

chfw commented Aug 3, 2019

here is relevant doc: about del() and what should can be performed in it.

https://docs.python.org/2/reference/datamodel.html#object.__del__

And it should explain a bit on why we will get ignored exceptions in del()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants