summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@gmail.com>2014-10-11 15:18:45 -0700
committerJoshua Harlow <harlowja@gmail.com>2014-10-11 15:18:45 -0700
commit46385c80c73671751c72c6c5fb68e34f0d7bdfaf (patch)
tree9cb671db1a7882546ed16ddecf0a200083fc9a1f
parent908aadf4c03110f0be630c601717eca9e3872e59 (diff)
downloadsix-fix-delattr.tar.gz
Fix simulatenous delattrfix-delattr
When two or more threads enter the descriptor one of them will delete the attribute and the others will not be able to, we should handle that case more gracefully.
-rw-r--r--six.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/six.py b/six.py
index 4252fdf..0df4538 100644
--- a/six.py
+++ b/six.py
@@ -88,8 +88,12 @@ class _LazyDescr(object):
def __get__(self, obj, tp):
result = self._resolve()
setattr(obj, self.name, result) # Invokes __set__.
- # This is a bit ugly, but it avoids running this again.
- delattr(obj.__class__, self.name)
+ try:
+ # This is a bit ugly, but it avoids running this again by
+ # removing this descriptor.
+ delattr(obj.__class__, self.name)
+ except AttributeError:
+ pass
return result