Skip to content

Commit 89cc68c

Browse files
committed
Ignore flags on Py_slot_end
`Py_slot_invalid` with OPTIONAL can be used as a no-op slot
1 parent 70bf2aa commit 89cc68c

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

peps/pep-0820.rst

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,8 @@ Flags
368368
Effectively, consecutive slots with the HAS_FALLBACK flag, plus the first
369369
non-HAS_FALLBACK slot after them, form a “block” where the the interpreter
370370
will only consider the *first* slot in the block that it understands.
371-
If the entire block is to be optional, it should end with a ``Py_slot_end``
372-
with the OPTIONAL flag.
371+
If the entire block is to be optional, it should end with a
372+
slot with the OPTIONAL flag.
373373

374374
- ``PySlot_IS_PTR``: The data is stored in ``sl_ptr``, and must be cast to
375375
the appropriate type.
@@ -447,18 +447,15 @@ New slot IDs
447447
The following new slot IDs, usable for both type and module
448448
definitions, will be added:
449449

450-
- ``Py_slot_end`` (defined as ``0``)
450+
- ``Py_slot_end`` (defined as ``0``): Marks the end of a slots array.
451451

452-
- With ``sl_flags=Py_SLOT_OPTIONAL``, this slot is ignored.
453-
Otherwise, this slot marks the end of the slots array.
454-
- The ``PySlot_INTPTR`` flag is ignored.
455-
- Other flags ( ``PySlot_STATIC``, ``PySlot_HAS_FALLBACK``) are
456-
not allowed with ``Py_slot_end``.
452+
- The ``PySlot_INTPTR`` and ``PySlot_STATIC`` flags are ignored.
453+
- The ``PySlot_OPTIONAL`` and ``PySlot_HAS_FALLBACK`` flags are not
454+
allowed with ``Py_slot_end``.
457455

458456
- ``Py_slot_subslots``, ``Py_tp_slots``, ``Py_mod_slots``: see
459457
*Nested slot tables* above
460-
- ``Py_slot_invalid``: treated as an unknown slot ID. (Useful for testing
461-
how optional and fallback slots work.)
458+
- ``Py_slot_invalid``: treated as an unknown slot ID.
462459

463460
The following new slot IDs will be added to cover existing
464461
members of ``PyModuleDef``:

0 commit comments

Comments
 (0)