Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use identify_type_slots() and find_name_in_mro() in iter_slot_wrapper…
…s().
  • Loading branch information
ericsnowcurrently committed Aug 9, 2024
commit 2ebebd38d6af53533e45842a74abb7bf81cdbfb3
14 changes: 14 additions & 0 deletions Lib/test/support/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2737,6 +2737,20 @@ def is_slot_wrapper(name, value):
assert name.startswith('__') and name.endswith('__'), (cls, name, value)
return True

try:
slots, duplicates = identify_type_slots(reverse=True)
except NotImplementedError:
slots = None
if slots is not None:
for attr in sorted(slots):
obj, base = find_name_in_mro(cls, attr, None)
if obj is not None and is_slot_wrapper(attr, obj):
slot = slots[attr]
yield attr, base is cls
return

# Fall back to a naive best-effort approach.

ns = vars(cls)
unused = set(ns)
for name in dir(cls):
Expand Down