From 5b3f5951b3c6f905fc20fd649231df99689d6c9b Mon Sep 17 00:00:00 2001 From: Tom Gillespie Date: Tue, 1 Oct 2019 21:47:41 -0700 Subject: [PATCH] CachePath fixed bad cache from __new__ surviving error in __init__ when initing a cache if a NoCachedMetadataError is raised then delete the _cache attribute from the _local path to avoid wierdness this manifested as a NameError in data.setter where cmeta could not be bound the first time, but the stale ref to a non-existent _cache would cause the second if statement to fire --- augpathlib/caches.py | 1 + augpathlib/core.py | 1 + 2 files changed, 2 insertions(+) diff --git a/augpathlib/caches.py b/augpathlib/caches.py index ffd1703..80493f1 100644 --- a/augpathlib/caches.py +++ b/augpathlib/caches.py @@ -100,6 +100,7 @@ def __init__(self, *args, meta=None, remote=None, **kwargs): self._meta_updater(meta) else: if self.meta is None: + delattr(self._local, '_cache') raise exc.NoCachedMetadataError(self.local) super().__init__() diff --git a/augpathlib/core.py b/augpathlib/core.py index 8477199..03abb88 100644 --- a/augpathlib/core.py +++ b/augpathlib/core.py @@ -594,6 +594,7 @@ def data(self): def data(self, generator): if self.cache is not None: cmeta = self.cache.meta + # FIXME do we touch a file, write the meta # and then write the data? # do we touch a temporary file, write the meta