diff options
| author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2021-08-04 13:09:45 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-08-04 22:09:45 +0200 |
| commit | 7dad0337518a0d599caf8f803a5bf45db67cbe9b (patch) | |
| tree | 3ac1a1a0f5c68a4b05ea8d80d6c3ed1e7110bdc4 | |
| parent | 1a2c0ecfa2ef8542baee951f12b60afd165be9cf (diff) | |
| download | cpython-git-7dad0337518a0d599caf8f803a5bf45db67cbe9b.tar.gz | |
bpo-42958: Improve description of shallow= in filecmp.cmp docs (GH-27166) (GH-27608)
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
Co-authored-by: Alexander Vandenbulcke <alexander.vandenbulcke95@gmail.com>
(cherry picked from commit a8dc4893d2b28827e82447326ea47759c161a722)
Co-authored-by: andrei kulakov <andrei.avk@gmail.com>
| -rw-r--r-- | Doc/library/filecmp.rst | 7 | ||||
| -rw-r--r-- | Lib/filecmp.py | 5 | ||||
| -rw-r--r-- | Misc/NEWS.d/next/Documentation/2021-07-15-11-19-03.bpo-42958.gC5IHM.rst | 2 |
3 files changed, 10 insertions, 4 deletions
diff --git a/Doc/library/filecmp.rst b/Doc/library/filecmp.rst index 31b9b4afab..1d04c3ef9f 100644 --- a/Doc/library/filecmp.rst +++ b/Doc/library/filecmp.rst @@ -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. diff --git a/Lib/filecmp.py b/Lib/filecmp.py index 7a4da6beb5..1893f909de 100644 --- a/Lib/filecmp.py +++ b/Lib/filecmp.py @@ -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: diff --git a/Misc/NEWS.d/next/Documentation/2021-07-15-11-19-03.bpo-42958.gC5IHM.rst b/Misc/NEWS.d/next/Documentation/2021-07-15-11-19-03.bpo-42958.gC5IHM.rst new file mode 100644 index 0000000000..c93b84d095 --- /dev/null +++ b/Misc/NEWS.d/next/Documentation/2021-07-15-11-19-03.bpo-42958.gC5IHM.rst @@ -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. |
