[issue1234674] filecmp.cmp's "shallow" option

Steven Barker report at bugs.python.org
Mon Aug 4 01:52:17 CEST 2014


Steven Barker added the comment:

I've worked on this filecmp issue some more, and I have some new patches.

First up is a patch that only modifies the tests. It has one test that fails without the behavior patch. The test patch also modifies some other tests so that they will work after the behavior patch is applied. Notably, test_keyword had a some tests that would fail due to false negatives on shallow comparisons.

The second patch is the behavior and documentation changes required to actually fix this issue. This should be very simple to understand (the behavior change is only two lines of code, quoted in the discussion above). If you apply only this patch, you'll get several test failures, all due to false negative shallow comparisons (where two files have the same contents, but their stat signatures differ).

With these new patches, I think this issue is ready for a review, and eventually to be committed. The behavior change is simple and I think, obviously correct (assuming we want to risk breaking backwards compatibility). Perhaps my test code can be improved, but I don't think it's too bad.

So, the main question is "will too much outside code break if we make this behavior change?"

I don't think filecmp is used very widely, but as was demonstrated by the standard library's only use of filecmp (in Lib/test/test_keyword.py), it's likely that a lot of users perform shallow comparisons (by default) where they really don't want to get false-negatives. If we decide that the changed behavior is too big of a break of backwards compatibility, we just need to document the current behavior better (at a minimum, the docstring for filecmp.cmp must be corrected).

----------
Added file: http://bugs.python.org/file36238/filecmp_test_patch.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue1234674>
_______________________________________


More information about the Python-bugs-list mailing list