12 Commits

Author SHA1 Message Date
Jeong, YunWon
c578ac0b21 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
Lee Dogeon
e8698aa19f Match SymbolTable repr with CPython format (#7139) 2026-02-14 22:59:42 +09:00
ShaharNaveh
ec906679b9 Update symtable from 3.14.2 2026-01-30 19:13:59 +02:00
Shahar Naveh
7f1fc3602f Add symtable.py from 3.13.5 (#6048)
* Add `symtable.py` from 3.13.5

* Update symtable methods

* Correct `type` return type
2025-08-01 22:12:11 +09:00
yt2b
f3eb95271e Remove the decorator 2022-12-24 14:38:44 +09:00
yt2b
59c6c6f7f1 Remove the decorator 2022-12-22 23:31:23 +09:00
Jeong YunWon
934fe3586f mark failing tests from test_symtable 2022-08-09 06:38:59 +09:00
CPython Developers
d399953aba Update test_symtable from CPython 3.10.5 2022-08-09 06:38:55 +09:00
Noah
7c58f4a0c8 Fast locals part 3 2020-12-05 16:36:35 -06:00
Jeong YunWon
9e9163b43a unskip test_symtable 2020-11-12 11:30:33 +09:00
Yiqun Ling
230f91582f Add nested and optimized for symtable 2020-08-13 04:12:28 +09:00
lynskylate
8a6ac64f03 Introduce symtable test and add is_annotation for symbol 2020-07-31 02:11:00 +08:00