https://github.com/python/cpython/commit/8448552579f94a9438ac9936c233b1d35f685ded
commit: 8448552579f94a9438ac9936c233b1d35f685ded
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: picnixz <[email protected]>
date: 2025-01-13T10:40:22Z
summary:

[3.12] gh-123345: improve `fnmatch` docs (GH-123346) (#128775)

gh-123345: improve `fnmatch` docs (GH-123346)
(cherry picked from commit 29fe8072cf404b891dde9c1d415095edddbe19de)

Co-authored-by: Bénédikt Tran <[email protected]>

files:
M Doc/library/fnmatch.rst

diff --git a/Doc/library/fnmatch.rst b/Doc/library/fnmatch.rst
index fda44923f204fc..5cb47777ae527d 100644
--- a/Doc/library/fnmatch.rst
+++ b/Doc/library/fnmatch.rst
@@ -46,9 +46,15 @@ module.  See module :mod:`glob` for pathname expansion 
(:mod:`glob` uses
 a period are not special for this module, and are matched by the ``*`` and 
``?``
 patterns.
 
-Also note that :func:`functools.lru_cache` with the *maxsize* of 32768 is used 
to
-cache the compiled regex patterns in the following functions: :func:`fnmatch`,
-:func:`fnmatchcase`, :func:`.filter`.
+Unless stated otherwise, "filename string" and "pattern string" either refer to
+:class:`str` or ``ISO-8859-1`` encoded :class:`bytes` objects. Note that the
+functions documented below do not allow to mix a :class:`!bytes` pattern with
+a :class:`!str` filename, and vice-versa.
+
+Finally, note that :func:`functools.lru_cache` with a *maxsize* of 32768
+is used to cache the (typed) compiled regex patterns in the following
+functions: :func:`fnmatch`, :func:`fnmatchcase`, :func:`.filter`.
+
 
 .. function:: fnmatch(name, pat)
 
@@ -78,8 +84,8 @@ cache the compiled regex patterns in the following functions: 
:func:`fnmatch`,
 
 .. function:: filter(names, pat)
 
-   Construct a list from those elements of the :term:`iterable` *names*
-   that match pattern *pat*.
+   Construct a list from those elements of the :term:`iterable` of filename
+   strings *names* that match the pattern string *pat*.
    It is the same as ``[n for n in names if fnmatch(n, pat)]``,
    but implemented more efficiently.
 
@@ -87,7 +93,7 @@ cache the compiled regex patterns in the following functions: 
:func:`fnmatch`,
 .. function:: translate(pat)
 
    Return the shell-style pattern *pat* converted to a regular expression for
-   using with :func:`re.match`.
+   using with :func:`re.match`. The pattern is expected to be a :class:`str`.
 
    Example:
 

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to