Skip to content

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

Closed

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.

Activity

  1. chfw commented on Aug 3, 2019

    @chfw
    ContributorAuthor

    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()

  2. self-assigned this
    on Aug 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions