| 101 | |
| 102 | |
| 103 | def _collects_classes() -> bool: |
| 104 | # GraalPy can collect a plain class while retaining one instantiated through a custom metaclass. |
| 105 | class ProbeMeta(type): |
| 106 | def __call__(cls: type[_T]) -> _T: |
| 107 | return type.__call__(cls) |
| 108 | |
| 109 | def build() -> type: |
| 110 | class Probe(metaclass=ProbeMeta): |
| 111 | pass |
| 112 | |
| 113 | Probe() |
| 114 | return Probe |
| 115 | |
| 116 | reference: Final[weakref.ReferenceType[type]] = weakref.ref(build()) |
| 117 | gc.collect() |
| 118 | return reference() is None |
| 119 | |
| 120 | |
| 121 | def _preserves_context_thrown_into_a_generator() -> bool: |