_not_tracked_instantly() requires the tuple to be untracked without a collection. This holds for tuples created at run time, but tuple constants are created tracked and are only untracked by _PyTuple_MaybeUntrack(), which is called only from the collector.
There are two aspects to this problem: one with flowgraph optimizations (the CFG should produce untracked tuples where possible), and the second with marshal (since optimization results are cached in __pycache__).
I'd like to open two separate PRs — one for flowgraph + tupleobject changes, one for marshal.
Activity
serhiy-storchaka commented on Aug 13, 2026
The failing test assertion were added in #140575. cc @vstinner, @efimov-mikhail.
sergey-miryanov commented on Aug 13, 2026
Do you mind I will take this?
serhiy-storchaka commented on Aug 13, 2026
You are welcome.
vstinner commented on Aug 13, 2026
Maybe (1,) can be rewritten as x=1; (x,) to avoid storing the tuple as a constant.
I understand that this issue is more theorical since it's not possible to get a failure when running test_tuple.
serhiy-storchaka commented on Aug 13, 2026
You can get failure by running ./python -m test test_tuple -m test_track_literals.
It means that the test asserts wrong condition. The result depends on previously executed code, it is not invariant.
vstinner commented on Aug 13, 2026
Ah thanks, it's good to have a way to reproduce the issue.
sergey-miryanov commented on Aug 24, 2026
There are two aspects to this problem: one with flowgraph optimizations (the CFG should produce untracked tuples where possible), and the second with marshal (since optimization results are cached in __pycache__).
I'd like to open two separate PRs — one for flowgraph + tupleobject changes, one for marshal.
Does that work?
@vstinner @serhiy-storchaka