GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix %reset -f not starting a new session by xh123637 · Pull Request #15473 · ipython/ipython

Conversation

@xh123637

@xh123637 xh123637 commented Nov 6, 2026

Copy link
Copy Markdown

Fix %reset -f not starting a new session

Fixes #13087.

%reset -f is documented as a hard reset that gives you a new session, and the magic's docstring shows the prompt going back to In [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 %reset magic called self.shell.reset(new_session=False, ...), so InteractiveShell.reset neither opened a new history session nor reset execution_count to 1. The False dates back to b24bd65 (2011), which also changed the magic from new_session=True; maintainer MrMino confirmed on the issue that this is a regression against the docstring. The only other caller passing False is _atexit_once, where no new session is wanted because the shell is exiting; it is untouched. The soft-reset path (-s) does not call shell.reset at all and is unaffected.

Fix

Pass new_session=True in the hard-reset branch, restoring the documented behavior: the namespace is cleared, a new history session starts, and the next prompt is In [1].

Tests

New regression test test_reset_starts_new_session in tests/test_magic.py: after two cells, %reset -f leaves execution_count == 1, starts a new history session, clears the namespace, and the next cell is numbered In [1]. The test fails on unmodified code (assert 3 == 1 for the prompt counter).

test_save_with_no_args also 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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
xh123637 added 2 commits November 6, 2026 15:58
@xh123637
Add regression test for %reset -f starting a new session
4c2d80c
@xh123637
Fix %reset -f not starting a new session
3989ffd

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

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

magic command reset is not working

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@xh123637
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.