[diffoscope] 01/01: Fix FileNotFoundError with broken symlinks

Mattia Rizzolo mattia at debian.org
Sun May 29 19:14:53 CEST 2016


This is an automated email from the git hooks/post-receive script.

mattia pushed a commit to branch master
in repository diffoscope.

commit 3952c7ef6c2530ba073e9a14dc91895782251157
Author: Mattia Rizzolo <mattia at debian.org>
Date:   Sun May 29 17:08:54 2016 +0000

    Fix FileNotFoundError with broken symlinks
    
    Closes: #818856
---
 diffoscope/comparators/binary.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/diffoscope/comparators/binary.py b/diffoscope/comparators/binary.py
index 9663214..14c0613 100644
--- a/diffoscope/comparators/binary.py
+++ b/diffoscope/comparators/binary.py
@@ -182,8 +182,13 @@ class File(object, metaclass=ABCMeta):
     def has_same_content_as(self, other):
         logger.debug('%s has_same_content %s', self, other)
         # try comparing small files directly first
-        my_size = os.path.getsize(self.path)
-        other_size = os.path.getsize(other.path)
+        try:
+            my_size = os.path.getsize(self.path)
+            other_size = os.path.getsize(other.path)
+        except OSError:
+            # files not readable (e.g. broken symlinks) or something else,
+            # just assume they are different
+            return False
         if my_size == other_size and my_size <= SMALL_FILE_THRESHOLD:
             if open(self.path, 'rb').read() == open(other.path, 'rb').read():
                 return True

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git


More information about the diffoscope mailing list