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

Created on 2012-07-26 00:00 by chris.jerdonek, last changed 2018-01-03 09:57 by mitar.

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 open mitar, 2018-01-03 09:57
Messages (5)
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.
History
Date User Action Args
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