Clarify description of __match_kind__. Drop claims of improved security (#1822)
This commit is contained in:
parent
79fdaaad0b
commit
89183f61d1
13
pep-0653.rst
13
pep-0653.rst
|
@ -424,12 +424,12 @@ Non-conforming ``__match_kind__``
|
|||
'''''''''''''''''''''''''''''''''
|
||||
|
||||
All classes should ensure that the the value of ``__match_kind__`` follows the specification.
|
||||
Therefore, implementations can assume, without checking, that all the following are *false*::
|
||||
Therefore, implementations can assume, without checking, that all the following are true::
|
||||
|
||||
(__match_kind__ & (MATCH_SEQUENCE | MATCH_MAPPING)) == (MATCH_SEQUENCE | MATCH_MAPPING)
|
||||
(__match_kind__ & (MATCH_SELF | MATCH_CLASS)) == (MATCH_SELF | MATCH_CLASS)
|
||||
(__match_kind__ & (MATCH_SELF | MATCH_DEFAULT)) == (MATCH_SELF | MATCH_DEFAULT)
|
||||
(__match_kind__ & (MATCH_DEFAULT | MATCH_CLASS)) == (MATCH_DEFAULT | MATCH_CLASS)
|
||||
(__match_kind__ & (MATCH_SEQUENCE | MATCH_MAPPING)) != (MATCH_SEQUENCE | MATCH_MAPPING)
|
||||
(__match_kind__ & (MATCH_SELF | MATCH_CLASS)) != (MATCH_SELF | MATCH_CLASS)
|
||||
(__match_kind__ & (MATCH_SELF | MATCH_DEFAULT)) != (MATCH_SELF | MATCH_DEFAULT)
|
||||
(__match_kind__ & (MATCH_DEFAULT | MATCH_CLASS)) != (MATCH_DEFAULT | MATCH_CLASS)
|
||||
|
||||
Thus, implementations can assume that ``__match_kind__ & MATCH_SEQUENCE`` implies ``(__match_kind__ & MATCH_MAPPING) == 0``, and vice-versa.
|
||||
Likewise for ``MATCH_SELF``, ``MATCH_CLASS`` and ``MATCH_DEFAULT``.
|
||||
|
@ -482,8 +482,7 @@ Implementations are also allowed to freely replace ``isinstance(obj, cls)`` with
|
|||
Security Implications
|
||||
=====================
|
||||
|
||||
Preventing the possible registering or unregistering of classes as sequences or a mappings, that PEP 634 allows,
|
||||
should improve security. However, the advantage is slight and is not a motivation for this PEP.
|
||||
None.
|
||||
|
||||
Implementation
|
||||
==============
|
||||
|
|
Loading…
Reference in New Issue