Skip to content

bpo-42958: Align docstring and filecmp.cmp() for shallow compare #24246

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

Closed
wants to merge 2 commits into from
Closed
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
9 changes: 7 additions & 2 deletions Doc/library/filecmp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@ 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, files with identical :func:`os.stat` signatures (file
type, size and modification time) are taken to be equal.

If the files have a different size ``False`` will be returned.

Comparisons with ``shallow=False`` or different signatures imply that the
contents of the files are compared.

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

f2 -- Second file name

shallow -- Just check stat signature (do not read the files).
shallow -- Check file signatures instead of contents, the
signature contains the file its mode, size and
mtime.
If the size differs, the files are considerd to be
different.
If other parts of the signature indicate that the files
differ, a deep compare is performed.
defaults to True.

Return value:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Clarify filecmp.cmp() docstring and documentation