Files
RustPython/Lib/test
Jeong, YunWonandCPython Developers 23c8eb80fb gc: add CollectResult, stats fields, get_referrers, and fix count reset (#7354)
* gc: add CollectResult, stats fields, get_referrers, and fix count reset

- Add CollectResult struct with collected/uncollectable/candidates/duration
- Add candidates and duration fields to GcStats and gc.get_stats()
- Pass CollectResult to gc.callbacks info dict
- Reset generation counts for all collected generations (0..=N)
- Return 0 for third value in gc.get_threshold() (3.13+)
- Implement gc.get_referrers() by scanning all tracked objects
- Add DEBUG_COLLECTABLE output for collectable objects
- Update test_gc.py to expect candidates/duration in stats

* Update test_gc from v3.14.3

* Update test_gc.py from CPython v3.15.0a5

Taken from v3.15 (not v3.14.3) because get_stats() candidates/duration
fields were added in 3.13+ and the corresponding test assertions only
exist in 3.15.

* Fix gc_state build on wasm32: skip Instant timing

* Add candidates/duration to gc callback info, mark v3.15 test failures

* Fix gc.get_referrers to exclude executing frames, fix Future cancelled exc leak

- get_referrers: skip frame objects on the execution stack, since
  they are not GC-tracked in CPython (_PyInterpreterFrame)
- _asyncio Future/Task make_cancelled_error_impl: clear the stored
  cancelled exception after returning it, matching the Python
  _make_cancelled_error behavior

* Fix gc.get_threshold to return actual gen2 threshold value

* Fix inconsistent GC count reset in early-return paths

Use the same reset_end formula in unreachable-empty early returns
as in the main collection path and collecting-empty path.

* Accept keyword arguments in socket.__init__

Use a FromArgs struct instead of a positional-only tuple so that
family, type, proto, and fileno can be passed as keyword arguments.

* Disable comp_inlined in symbol table to match compiler

The compiler does not yet implement PEP 709 inlined comprehensions
(is_inlined_comprehension_context always returns false), but the
symbol table was marking comprehensions as inlined. This mismatch
could cause comprehension-local symbols to be merged into the parent
scope while the compiler still looks them up in a separate scope.

---------

Co-authored-by: CPython Developers <>
2026-03-12 20:48:22 +09:00
..
2026-03-01 11:36:46 +09:00
2025-08-24 10:36:07 +03:00
2026-02-18 03:10:40 +09:00
2026-03-01 14:51:54 +09:00
2026-02-10 21:00:40 +09:00
2025-04-30 14:33:52 +09:00
2026-02-02 00:43:07 +09:00
2026-02-04 09:53:02 +09:00
2023-04-20 15:36:28 +09:00
2023-03-02 15:01:12 +09:00
2026-02-05 00:21:34 +09:00
2022-10-18 03:26:29 +09:00
2026-01-21 20:44:26 +09:00
2023-03-01 18:06:50 +09:00
2026-03-01 11:36:46 +09:00
2026-02-02 02:02:12 +09:00
2026-01-26 10:40:22 +09:00
2026-02-13 22:15:52 +09:00
2026-01-25 15:20:05 +09:00
2025-03-31 18:49:08 +09:00
2026-01-19 00:04:06 +09:00
2026-02-14 18:27:31 +02:00
2026-02-13 13:36:33 +02:00
2026-02-13 13:36:33 +02:00
2026-02-13 14:13:30 +09:00
2026-01-18 21:33:37 +09:00
2026-02-06 00:15:18 +09:00
2025-03-26 02:24:01 -05:00
2025-12-12 09:23:59 +09:00
2025-12-30 16:58:53 +09:00
2024-06-24 19:00:54 +09:00
2026-02-18 00:43:49 +09:00
2026-02-11 16:50:23 +09:00
2026-01-30 16:39:33 +02:00
2026-02-13 18:06:47 +09:00
2026-02-06 00:35:00 +09:00
2026-02-08 20:36:35 +09:00
2026-03-01 14:51:54 +09:00
2026-01-17 19:22:00 +09:00
2025-09-01 11:19:00 +03:00
2026-02-10 00:48:22 +09:00
fix
2026-02-12 01:01:35 +09:00
2026-02-06 00:15:18 +09:00
2026-02-13 13:36:33 +02:00
2026-01-30 07:48:29 +09:00
2026-03-03 15:20:36 +01:00
2026-01-10 22:10:35 -05:00
2026-02-11 18:38:10 +09:00
2026-02-03 22:10:31 +09:00
2026-02-06 00:15:18 +09:00
2026-02-01 19:45:06 -05:00
2026-02-13 13:55:05 +09:00
2023-03-02 05:56:34 +09:00
2026-03-06 06:00:08 +09:00
2026-02-13 13:55:05 +09:00
2026-02-14 18:19:57 +02:00
2026-03-01 14:51:54 +09:00
2026-01-25 00:18:55 +09:00
2026-01-25 00:18:55 +09:00
2025-08-23 19:25:28 +03:00
2026-01-26 10:40:22 +09:00
2026-03-01 14:51:54 +09:00
2026-01-31 21:23:23 -05:00
2026-03-03 20:00:50 +09:00
2026-02-06 00:15:18 +09:00
2025-04-28 12:29:21 +09:00
2026-02-03 22:10:31 +09:00
2026-03-12 18:08:56 +09:00
2025-08-31 11:58:21 +03:00
2026-02-06 01:14:55 +09:00
2026-02-13 13:36:33 +02:00
2026-02-27 09:44:41 +01:00
2026-02-04 18:32:45 +09:00
2026-03-03 19:57:50 +09:00
2026-02-28 22:50:51 +09:00
2022-07-27 14:43:47 +09:00
2026-02-06 00:15:18 +09:00
2026-01-25 00:18:55 +09:00
2026-02-27 10:05:21 +01:00
2025-04-21 21:11:42 -07:00
2026-02-15 23:40:14 +09:00
2026-02-04 09:53:02 +09:00
2026-01-31 20:51:53 -05:00
2025-12-12 10:37:40 +09:00
2026-02-15 09:02:24 +09:00
2026-02-03 22:10:31 +09:00
2026-02-05 23:50:08 +09:00
2026-02-14 21:40:04 +09:00
2026-02-08 08:33:45 +09:00
2026-03-01 11:36:46 +09:00
2026-02-14 09:18:09 +09:00
2026-03-01 10:42:37 +09:00
2025-03-26 23:12:21 -05:00
2026-03-01 10:42:37 +09:00
2026-02-14 22:02:24 +09:00
2026-02-11 16:57:51 +09:00
2026-02-27 22:59:41 +09:00
2025-06-22 22:36:13 +09:00
2026-02-27 16:53:55 +09:00
2026-03-01 20:50:21 +09:00
2026-03-08 18:06:23 +09:00
2026-03-03 21:58:46 +09:00
2026-02-02 01:20:23 +09:00
2025-01-17 18:04:25 -08:00
2026-02-17 01:31:29 +09:00
2026-01-25 00:18:55 +09:00
2026-01-25 00:18:55 +09:00
2026-02-13 13:44:28 +09:00
2026-01-25 00:18:55 +09:00
2026-02-06 00:15:18 +09:00
2025-12-20 12:17:11 +09:00
2026-02-13 13:42:22 +09:00
2026-01-25 00:18:55 +09:00
2026-02-15 23:44:23 +09:00
2026-02-27 09:49:35 +01:00
2026-02-14 18:18:53 +02:00
2026-02-11 16:50:23 +09:00
2026-03-05 17:25:59 +09:00
2023-04-20 15:36:28 +09:00