@@ -94,7 +94,7 @@ def onerror(func, path, exc_info):
94
94
func (path ) # Will scream if still not possible to delete.
95
95
except Exception as ex :
96
96
if HIDE_WINDOWS_KNOWN_ERRORS :
97
- raise SkipTest ("FIXME: fails with: PermissionError\n {}" .format (ex ))
97
+ raise SkipTest ("FIXME: fails with: PermissionError\n {}" .format (ex )) from ex
98
98
raise
99
99
100
100
return shutil .rmtree (path , False , onerror )
@@ -746,7 +746,7 @@ def _obtain_lock_or_raise(self):
746
746
fd = os .open (lock_file , flags , 0 )
747
747
os .close (fd )
748
748
except OSError as e :
749
- raise IOError (str (e ))
749
+ raise IOError (str (e )) from e
750
750
751
751
self ._owns_lock = True
752
752
@@ -801,19 +801,19 @@ def _obtain_lock(self):
801
801
while True :
802
802
try :
803
803
super (BlockingLockFile , self )._obtain_lock ()
804
- except IOError :
804
+ except IOError as e :
805
805
# synity check: if the directory leading to the lockfile is not
806
806
# readable anymore, raise an exception
807
807
curtime = time .time ()
808
808
if not osp .isdir (osp .dirname (self ._lock_file_path ())):
809
809
msg = "Directory containing the lockfile %r was not readable anymore after waiting %g seconds" % (
810
810
self ._lock_file_path (), curtime - starttime )
811
- raise IOError (msg )
811
+ raise IOError (msg ) from e
812
812
# END handle missing directory
813
813
814
814
if curtime >= maxtime :
815
815
msg = "Waited %g seconds for lock at %r" % (maxtime - starttime , self ._lock_file_path ())
816
- raise IOError (msg )
816
+ raise IOError (msg ) from e
817
817
# END abort if we wait too long
818
818
time .sleep (self ._check_interval )
819
819
else :
@@ -878,8 +878,8 @@ def __getitem__(self, index):
878
878
879
879
try :
880
880
return getattr (self , index )
881
- except AttributeError :
882
- raise IndexError ("No item found with id %r" % (self ._prefix + index ))
881
+ except AttributeError as e :
882
+ raise IndexError ("No item found with id %r" % (self ._prefix + index )) from e
883
883
# END handle getattr
884
884
885
885
def __delitem__ (self , index ):
0 commit comments