8000 bpo-42958: Improve description of shallow= in filecmp.cmp docs (GH-27… · python/cpython@a8dc489 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit a8dc489

Browse files
akulakovambvAlexVndn
8000
blcke
authored
bpo-42958: Improve description of shallow= in filecmp.cmp docs (GH-27166)
Co-authored-by: Łukasz Langa <lukasz@langa.pl> Co-authored-by: Alexander Vandenbulcke <alexander.vandenbulcke95@gmail.com>
1 parent 7c5dab4 commit a8dc489

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

Doc/library/filecmp.rst

Lines changed: 5 additions & 2 deletions
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

Lines changed: 3 additions & 2 deletions
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
Lines changed: 2 additions & 0 deletions
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)
0