(lst)
| 2021 | exc.append(ex) |
| 2022 | |
| 2023 | def pop_and_collect(lst): |
| 2024 | gc_ctr = 0 |
| 2025 | while lst: |
| 2026 | i = random.randint(0, len(lst) - 1) |
| 2027 | gc_ctr += 1 |
| 2028 | lst.pop(i) |
| 2029 | if gc_ctr % 10000 == 0: |
| 2030 | gc.collect() # just in case |
| 2031 | |
| 2032 | self.assertIn(type_, (weakref.WeakKeyDictionary, weakref.WeakValueDictionary)) |
| 2033 |