Skip to content

[3.9] bpo-42958: Improve description of shallow= in filecmp.cmp docs (GH-27166) #27608

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Doc/library/filecmp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ The :mod:`filecmp` module defines the following functions:
Compare the files named *f1* and *f2*, returning ``True`` if they seem equal,
``False`` otherwise.

If *shallow* is true, files with identical :func:`os.stat` signatures are
taken to be equal. Otherwise, the contents of the files are compared.
If *shallow* is true and the :func:`os.stat` signatures (file type, size, and
modification time) of both files are identical, the files are taken to be
equal.

Otherwise, the files are treated as different if their sizes or contents differ.

Note that no external programs are called from this function, giving it
portability and efficiency.
Expand Down
5 changes: 3 additions & 2 deletions Lib/filecmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ def cmp(f1, f2, shallow=True):

f2 -- Second file name

shallow -- Just check stat signature (do not read the files).
defaults to True.
shallow -- treat files as identical if their stat signatures (type, size,
mtime) are identical. Otherwise, files are considered different
if their sizes or contents differ. [default: True]

Return value:

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Updated the docstring and docs of :func:`filecmp.cmp` to be more accurate
and less confusing especially in respect to *shallow* arg.