Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix %reset -f not starting a new session
Fixes #13087.
%reset -fis documented as a hard reset that gives you a new session, and the magic's docstring shows the prompt going back toIn [1]. Instead the prompt counter kept counting (In [35]→In [36]) and no new history session was created.Root cause
The hard-reset branch of the
%resetmagic calledself.shell.reset(new_session=False, ...), soInteractiveShell.resetneither opened a new history session nor resetexecution_countto 1. TheFalsedates back to b24bd65 (2011), which also changed the magic fromnew_session=True; maintainer MrMino confirmed on the issue that this is a regression against the docstring. The only other caller passingFalseis_atexit_once, where no new session is wanted because the shell is exiting; it is untouched. The soft-reset path (-s) does not callshell.resetat all and is unaffected.Fix
Pass
new_session=Truein the hard-reset branch, restoring the documented behavior: the namespace is cleared, a new history session starts, and the next prompt isIn [1].Tests
New regression test
test_reset_starts_new_sessionintests/test_magic.py: after two cells,%reset -fleavesexecution_count == 1, starts a new history session, clears the namespace, and the next cell is numberedIn [1]. The test fails on unmodified code (assert 3 == 1for the prompt counter).test_save_with_no_argsalso starts a fresh history session at the end: it stores inputs with hardcoded line numbers 1-4 in the shared test shell, and with the counter now restarting at 1, later cells could reuse those line numbers in the same session and trip the history database's UNIQUE(session, line) constraint. The extra reset isolates the faked entries.AI usage
Worked on with Muse (Muse Spark 1.3); reasoning effort level unknown.