summaryrefslogtreecommitdiffstats
path: root/Lib/filecmp.py
diff options
context:
space:
mode:
authorNick Crews <nicholas.b.crews@gmail.com>2020-11-23 16:29:37 (GMT)
committerGitHub <noreply@github.com>2020-11-23 16:29:37 (GMT)
commit2f2f9d0b5c96e68ed91cddd6673860ee752eb49c (patch)
treec67e28aae082232cf110fb46cac133b678e1900f /Lib/filecmp.py
parentff420f0e08a2443339da0df7ace95e14177bac53 (diff)
downloadcpython-2f2f9d0b5c96e68ed91cddd6673860ee752eb49c.zip
cpython-2f2f9d0b5c96e68ed91cddd6673860ee752eb49c.tar.gz
cpython-2f2f9d0b5c96e68ed91cddd6673860ee752eb49c.tar.bz2
bpo-15450: Allow subclassing of dircmp (GH-23424) (#23424)
Co-authored-by: Chris Jerdonek <chris.jerdonek@gmail.com>
Diffstat (limited to 'Lib/filecmp.py')
-rw-r--r--Lib/filecmp.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/Lib/filecmp.py b/Lib/filecmp.py
index 7a4da6b..7c47eb0 100644
--- a/Lib/filecmp.py
+++ b/Lib/filecmp.py
@@ -115,7 +115,9 @@ class dircmp:
same_files: list of identical files.
diff_files: list of filenames which differ.
funny_files: list of files which could not be compared.
- subdirs: a dictionary of dircmp objects, keyed by names in common_dirs.
+ subdirs: a dictionary of dircmp instances (or MyDirCmp instances if this
+ object is of type MyDirCmp, a subclass of dircmp), keyed by names
+ in common_dirs.
"""
def __init__(self, a, b, ignore=None, hide=None): # Initialize
@@ -185,14 +187,15 @@ class dircmp:
self.same_files, self.diff_files, self.funny_files = xx
def phase4(self): # Find out differences between common subdirectories
- # A new dircmp object is created for each common subdirectory,
+ # A new dircmp (or MyDirCmp if dircmp was subclassed) object is created
+ # for each common subdirectory,
# these are stored in a dictionary indexed by filename.
# The hide and ignore properties are inherited from the parent
self.subdirs = {}
for x in self.common_dirs:
a_x = os.path.join(self.left, x)
b_x = os.path.join(self.right, x)
- self.subdirs[x] = dircmp(a_x, b_x, self.ignore, self.hide)
+ self.subdirs[x] = self.__class__(a_x, b_x, self.ignore, self.hide)
def phase4_closure(self): # Recursively call phase4() on subdirectories
self.phase4()