filecmp.dircmp does not allow non-shallow comparisons
| BPO | 12932 |
|---|---|
| Nosy | @terryjreedy, @rbtcollins, @merwok, @regebro, @mitar, @cjerdonek |
| Files |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee = None
closed_at = None
created_at = <Date 2011-09-07.16:01:35.750>
labels = ['type-feature', 'library']
title = 'filecmp.dircmp does not allow non-shallow comparisons'
updated_at = <Date 2018-01-03.09:42:28.161>
user = 'https://bugs.python.org/kesmit'
bugs.python.org fields:
activity = <Date 2018-01-03.09:42:28.161>
actor = 'mitar'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2011-09-07.16:01:35.750>
creator = 'kesmit'
dependencies = []
files = ['30589']
hgrepos = []
issue_num = 12932
keywords = ['patch']
message_count = 9.0
messages = ['143692', '156736', '160966', '161823', '164648', '166246', '191154', '247695', '247696']
nosy_count = 8.0
nosy_names = ['terry.reedy', 'rbcollins', 'eric.araujo', 'lregebro', 'mitar', 'chris.jerdonek', 'planet36', 'kesmit']
pr_nums = []
priority = 'normal'
resolution = None
stage = 'patch review'
status = 'open'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue12932'
versions = ['Python 3.6']
Linked PRs
- gh-109499
- gh-121767
- gh-121777
While filecmp.cmp and filecmp.cmpfiles allow a shallow option to be specified to invoke a more involved comparison of files, filecmp.dircmp does not. It is limited to shallow-only comparisons.
This could be solved quite easily by adding a shallow keyword option to dircmp then changing the phase3 method to the following.
def phase3(self): # Find out differences between common files
xx = cmpfiles(self.left, self.right, self.common_files, self.shallow)
self.same_files, self.diff_files, self.funny_files = xx
Thanks for the report. Unfortunately 2.7 is closed to new features and the module is removed in 3.x, so there is nothing to do here.
filecmp is still there in Python 3.3 Alpha 3. I can't find any reference to it being deprecated.
Lennart, I saw your response on StackOverflow ;-).
+1 for this.
Whether or not this feature is implemented, I think the documentation should state that directory comparisons are done using "shallow=True". I created bpo-15250 for this.
Allowing dircmp() to accept a file comparison function is another option to consider that may address more needs going forward. shallow=False could be achieved by passing lambda a, b: filecmp.cmp(a, b, shallow=False).
Add input parameter 'shallow' to dircmp. Use it in phase3 and phase4. Document it in filecmp.rst.
Did not modify test_filecmp.py.
Thanks for the patch @planet36, however I think this is sufficiently large a change that we should also have a test case for it.
I'm also retargeting this to the current open branches for feature work - 3.6.
Bah, wrong stage. patch review.
@rbtcollins any update here?
You can see that the latest comment is from 2015.
Someone would need to take the patch, apply it to Python main branch, make sure tests, docs and changelog are present, and open a pull request. The devguide has help about that.
Thanks to everyone involved!
Really wish github would send a notif on the issue when a PR is created to solve it!
Not a bad idea. Did bpo do so? (I cannot remember either way for sure.)
Given the absence of such notices, the PR author should have requested a review from you. If not already, the devguide should say something about looking for participants (preferably recent) who are members of 'Python' or 'python/core'. (bpo starred our names on comments.)
Should the new parameter be made keyword-only? I feel we usually do that for newly added optional parameters. We have a little bit of time left before the RC phase to change this.
Submitted #121767 to make the new parameter keyword-only.
It looks like everything is done here, for real this time!