Skip to content

Fix dictionary pretty printing during mutation - #15468

Open
arshiya-md wants to merge 2 commits into
ipython:mainfrom
arshiya-md:fix/14541-vars-posix-runtime-error
Open

arshiya-md wants to merge 2 commits into
ipython:mainfrom
arshiya-md:fix/14541-vars-posix-runtime-error

Conversation

@arshiya-md

@arshiya-md arshiya-md commented Nov 2, 2026 •

Copy link
Copy Markdown

Fixes #14541.

The dictionary pretty printer previously iterated over a live dict_keys view. If formatting a dictionary value mutated the dictionary, iteration could raise RuntimeError: dictionary changed size during iteration.

This change snapshots dictionary keys before formatting values. When max_seq_length is configured, islice limits the snapshot to max_seq_length + 1 keys, avoiding unnecessary allocation proportional to the full dictionary size.

Tests

Added a regression test for dictionary mutation during value formatting.

Added a test verifying bounded key consumption with max_seq_length.

@arshiya-md
arshiya-md force-pushed the fix/14541-vars-posix-runtime-error branch from 0481bbc to d8d9faa Compare November 2, 2026 16:17

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RuntimeError on first call to vars(posix)

1 participant