New submission from Till Maas: If filecmp is used with files that the user is not allowed to read, it creates an IOError exception instead of returning the file's name as an file that could not compared. The documentation says:
http://docs.python.org/2/library/filecmp.html Returns three lists of file names: match, mismatch, errors. [...] errors lists the names of files which could not be compared. Files are listed in errors if they don’t exist in one of the directories, the user lacks permission to read them or if the comparison could not be done for some other reason. The attached file fails with an IOError: $ python filecmp-minimal.py Traceback (most recent call last): File "filecmp-minimal.py", line 21, in <module> print filecmp.cmpfiles(join(t, "a"), join(t, "b"), ["testfile"], shallow=False) File "/usr/lib64/python2.7/filecmp.py", line 258, in cmpfiles res[_cmp(ax, bx, shallow)].append(x) File "/usr/lib64/python2.7/filecmp.py", line 270, in _cmp return not abs(cmp(a, b, sh)) File "/usr/lib64/python2.7/filecmp.py", line 53, in cmp outcome = _do_cmp(f1, f2) File "/usr/lib64/python2.7/filecmp.py", line 66, in _do_cmp with open(f1, 'rb') as fp1, open(f2, 'rb') as fp2: IOError: [Errno 13] Permission denied: '/tmp/tmpp93pmt/a/testfile' A quick glance at the current code in hg shows, that this bug is probably also present in all later Python versions than 2.7. I will attach a small patch that fixes this bug. ---------- components: Library (Lib) files: filecmp-minimal.py messages: 176700 nosy: till priority: normal severity: normal status: open title: unhandled IOError filecmp.cmpfiles() if file not readable type: crash versions: Python 2.7 Added file: http://bugs.python.org/file28168/filecmp-minimal.py _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue16584> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com