[kupfer] objects: Catch OSError when comparing two files with samepath



commit 61c4d2dbf02dab1cdb06e1896cadda64e86eb87c
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Sun Oct 25 16:55:48 2009 +0100

    objects: Catch OSError when comparing two files with samepath
    
    In FileLeaf.__eq__ we might get an OSError when one of the two files
    do not exist in os.path.samepath. Here we handle this.

 kupfer/objects.py |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/kupfer/objects.py b/kupfer/objects.py
index b4151c6..9ce8f69 100644
--- a/kupfer/objects.py
+++ b/kupfer/objects.py
@@ -211,9 +211,13 @@ class FileLeaf (Leaf):
 		super(FileLeaf, self).__init__(obj, name)
 
 	def __eq__(self, other):
-		return (type(self) == type(other) and
-				unicode(self) == unicode(other) and
-				path.samefile(self.object, other.object))
+		try:
+			return (type(self) == type(other) and
+					unicode(self) == unicode(other) and
+					path.samefile(self.object, other.object))
+		except OSError, exc:
+			pretty.print_debug(__name__, exc)
+			return False
 
 	def repr_key(self):
 		return self.object



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]