]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Update pattern matching docs for changes to the PEP (#25185)
authorKen Jin <28750310+Fidget-Spinner@users.noreply.github.com>
Tue, 6 Apr 2021 16:03:00 +0000 (00:03 +0800)
committerGitHub <noreply@github.com>
Tue, 6 Apr 2021 16:03:00 +0000 (09:03 -0700)
See:
- https://github.com/python/peps/pull/1909 (__match_args__ must be a tuple)
- https://github.com/python/peps/pull/1908 (allow keyword patterns for int(x) etc.)

Doc/reference/compound_stmts.rst
Doc/reference/datamodel.rst

index e13d6dd956209f3ea15404a5a20fb8f2be5b2638..aae7c7f68b6e0500e86dca144988f92d5c3dd401 100644 (file)
@@ -1030,7 +1030,7 @@ subject value:
 
    For a number of built-in types (specified below), a single positional
    subpattern is accepted which will match the entire subject; for these types
-   no keyword patterns are accepted.
+   keyword patterns also work as for other types.
 
    If only keyword patterns are present, they are processed as follows,
    one by one:
@@ -1057,7 +1057,7 @@ subject value:
 
       * If this raises an exception, the exception bubbles up.
 
-      * If the returned value is not a list or tuple, the conversion fails and
+      * If the returned value is not a tuple, the conversion fails and
         :exc:`TypeError` is raised.
 
       * If there are more positional patterns than ``len(cls.__match_args__)``,
index dfe5eb6857c0f5368418af36546573a704700071..9c819b7ae6d28f9b1b6b3609c3c17e8b7f39c7d5 100644 (file)
@@ -2565,7 +2565,7 @@ define a *__match_args__* attribute.
 
 .. data:: object.__match_args__
 
-   This class variable can be assigned a tuple or list of strings. When this class is
+   This class variable can be assigned a tuple of strings. When this class is
    used in a class pattern with positional arguments, each positional argument will
    be converted into a keyword argument, using the corresponding value in
    *__match_args__* as the keyword. The absence of this attribute is equivalent to