This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Allow dircmp.subdirs to behave well under subclassing
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.10
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: NickCrews, asvetlov, cbc, chris.jerdonek, eli.bendersky, hynek, mitar
Priority: normal Keywords: easy, patch

Created on 2012-07-26 00:00 by chris.jerdonek, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue-15450-failing-test.patch chris.jerdonek, 2012-07-26 19:32 review
issue-15450-1.patch chris.jerdonek, 2012-07-26 19:41 review
issue-15450-2.patch chris.jerdonek, 2012-07-27 23:01 review
Pull Requests
URL Status Linked Edit
PR 5088 closed mitar, 2018-01-03 09:57
PR 23424 merged NickCrews, 2020-11-20 17:40
Messages (7)
msg166443 - (view) Author: Chris Jerdonek (chris.jerdonek) * (Python committer) Date: 2012-07-26 00:00
Currently, the subdirs attribute of filecmp.dircmp does not respect subclassing:

>>> from filecmp import dircmp
>>> class MyDirCmp(dircmp):
...   pass
... 
>>> my_dcmp = MyDirCmp('dir1', 'dir2')
>>> for item in my_dcmp.subdirs.values():
...   print(type(item))
...   break
... 
<class 'filecmp.dircmp'>

This is the only place where dircmp does not respect subclassing.  It can be corrected here:

def phase4(self): # Find out differences between common subdirectories
    ...
        ...
        self.subdirs[x]  = dircmp(a_x, b_x, self.ignore, self.hide)

This would let one do things like override dircmp.report() and have dircmp.report_full_closure() behave as expected.
msg166503 - (view) Author: Chris Jerdonek (chris.jerdonek) * (Python committer) Date: 2012-07-26 19:32
Adding a patch with a failing test for the issue.
msg166505 - (view) Author: Chris Jerdonek (chris.jerdonek) * (Python committer) Date: 2012-07-26 19:41
Attaching full patch (though Misc/NEWS would need to be moved a new section is created for pre-alpha).
msg166507 - (view) Author: Chris Jerdonek (chris.jerdonek) * (Python committer) Date: 2012-07-26 19:44
Actually, this should also be documented.
msg166618 - (view) Author: Chris Jerdonek (chris.jerdonek) * (Python committer) Date: 2012-07-27 23:01
Updating patch to include documentation changes.
msg381490 - (view) Author: Nick Crews (NickCrews) * Date: 2020-11-20 17:42
I re-did this at https://github.com/python/cpython/pull/23424, let me know what you think. This is my first PR here, so I may have pooched something.
msg381677 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2020-11-23 16:30
New changeset 2f2f9d0b5c96e68ed91cddd6673860ee752eb49c by Nick Crews in branch 'master':
bpo-15450: Allow subclassing of dircmp (GH-23424) (#23424)
https://github.com/python/cpython/commit/2f2f9d0b5c96e68ed91cddd6673860ee752eb49c
History
Date User Action Args
2022-04-11 14:57:33adminsetgithub: 59655
2020-11-23 16:31:26asvetlovsetstatus: open -> closed
stage: patch review -> resolved
resolution: fixed
versions: + Python 3.10, - Python 3.4
2020-11-23 16:30:06asvetlovsetnosy: + asvetlov
messages: + msg381677
2020-11-20 17:42:10NickCrewssetmessages: + msg381490
2020-11-20 17:40:40NickCrewssetnosy: + NickCrews
pull_requests: + pull_request22316
2018-01-03 09:57:12mitarsetpull_requests: + pull_request4962
2018-01-03 09:43:27mitarsetnosy: + mitar
2012-12-27 10:59:55hyneksetnosy: + hynek
2012-10-17 18:42:48petri.lehtinensetkeywords: + patch
2012-07-31 18:28:33chris.jerdoneksetnosy: + cbc
2012-07-28 02:36:38chris.jerdoneksetnosy: + eli.bendersky
2012-07-27 23:01:13chris.jerdoneksetkeywords: - patch
files: + issue-15450-2.patch
messages: + msg166618

stage: needs patch -> patch review
2012-07-26 19:44:10chris.jerdoneksetmessages: + msg166507
stage: patch review -> needs patch
2012-07-26 19:41:26chris.jerdoneksetstage: needs patch -> patch review
2012-07-26 19:41:19chris.jerdoneksetfiles: + issue-15450-1.patch

messages: + msg166505
2012-07-26 19:32:54chris.jerdoneksetfiles: + issue-15450-failing-test.patch
keywords: + patch
messages: + msg166503

stage: needs patch
2012-07-26 00:00:03chris.jerdonekcreate