Skip to content

Commit c2593b4

Browse files
bpo-42958: Improve description of shallow= in filecmp.cmp docs (GH-27166)
Co-authored-by: Łukasz Langa <[email protected]> Co-authored-by: Alexander Vandenbulcke <[email protected]> (cherry picked from commit a8dc489) Co-authored-by: andrei kulakov <[email protected]>
1 parent 98f6a72 commit c2593b4

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

Doc/library/filecmp.rst

+5-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ The :mod:`filecmp` module defines the following functions:
2222
Compare the files named *f1* and *f2*, returning ``True`` if they seem equal,
2323
``False`` otherwise.
2424

25-
If *shallow* is true, files with identical :func:`os.stat` signatures are
26-
taken to be equal. Otherwise, the contents of the files are compared.
25+
If *shallow* is true and the :func:`os.stat` signatures (file type, size, and
26+
modification time) of both files are identical, the files are taken to be
27+
equal.
28+
29+
Otherwise, the files are treated as different if their sizes or contents differ.
2730

2831
Note that no external programs are called from this function, giving it
2932
portability and efficiency.

Lib/filecmp.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ def cmp(f1, f2, shallow=True):
3636
3737
f2 -- Second file name
3838
39-
shallow -- Just check stat signature (do not read the files).
40-
defaults to True.
39+
shallow -- treat files as identical if their stat signatures (type, size,
40+
mtime) are identical. Otherwise, files are considered different
41+
if their sizes or contents differ. [default: True]
4142
4243
Return value:
4344
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Updated the docstring and docs of :func:`filecmp.cmp` to be more accurate
2+
and less confusing especially in respect to *shallow* arg.

0 commit comments

Comments
 (0)