Skip to content

Assorted self-contained bug fixes (history sqlite handles on Windows, …)#15255

Merged
Carreau merged 5 commits into
mainfrom
claude/gifted-hamilton-wa1x60
Jun 13, 2026
Merged

Assorted self-contained bug fixes (history sqlite handles on Windows, …)#15255
Carreau merged 5 commits into
mainfrom
claude/gifted-hamilton-wa1x60

Conversation

@Carreau

@Carreau Carreau commented Jun 12, 2026

Copy link
Copy Markdown
Member

A series of independent, self-contained fixes — one issue per commit, pushed separately so every commit gets its own complete test.yml run and is easy to review (and cherry-pick) individually.

Commits

  1. Close sqlite connections before replacing history databasefixes history clear/trim fails on Windows: PermissionError on history.sqlite (open SQLite handle blocks unlink) #15241.
    sqlite3.Connection used as a context manager only commits/rolls back, it does not close. ipython history trim/clear therefore still had open handles on history.sqlite while unlinking/renaming it, which fails with PermissionError on Windows and leaves history.sqlite.new* debris behind. Both connections are now wrapped in contextlib.closing, and a regression test runs the trim and clear subcommands in a subprocess (exercised on Windows CI). (all workflows green on this SHA)

  2. Make test_hist_file_config teardown deterministicfixes Flaky test - teardown in test_hist_file_config #15161.
    The test created a HistoryManager backed by a real file but never stopped its HistorySavingThread; the thread briefly holds a strong reference to the manager inside its polling loop, so the instance could survive the gc.collect() in the hmmax fixture teardown and trip the instance-leak assertion intermittently (~3/10 Fedora builds). The test now stops the thread and closes the db like the other tests in the file. (all workflows green on this SHA)

  3. Use tokenize.open to read source files in deduperreloadcloses UnicodeDecodeError in deduperreload on Windows (first %load_ext autoreload) #15193.
    Honor PEP 263 coding cookies when reading module sources for the autoreload diffing logic, the way the import system does. (The original cp1252 UnicodeDecodeError crash in that issue was already fixed by reading with an explicit utf-8 encoding; this handles the remaining non-utf-8 sources, which were silently treated as unpatchable with a noisy logged traceback.) The regression test fails with the previous explicit-utf-8 reading.

  4. Deprecate IPython.utils.generics.inspect_object — first step towards deprecated and remove IPython/utils/generics.py #15068.
    inspect_object is not called anywhere in IPython anymore and no public external users were found (unlike complete_object, which pyflyby/riptable/maiev register completers on, and which is unchanged). The DeprecationWarning is emitted through a module __getattr__, so simply importing the name warns — covering consumers that only call .register().

  5. Add regression test for SyntaxError subclasses without textcloses AssertionError while rendering traceback in ipython 9.6.0 #15024.
    xml.etree.ElementTree.ParseError leaves .text as None; 9.6.0 raised an AssertionError rendering it. The guard landed with Fix #15011, Exception.text may be None #15012 but had no test; this locks the behavior in (the test fails if the None check in ListTB._format_exception_only is removed).

Notes from triage

https://claude.ai/code/session_01AtmUVnQwZfjDBuUzF7TdGh

claude added 5 commits June 12, 2026 19:58
sqlite3.Connection used as a context manager only commits or rolls
back, it does not close the connection. `ipython history trim/clear`
therefore still had open handles on history.sqlite when unlinking and
renaming it, which fails with PermissionError on Windows and leaves
history.sqlite.new* files behind.

Wrap both connections in contextlib.closing so they are closed before
any file shuffling, and add a regression test running the trim and
clear subcommands in a subprocess.

Fixes #15241

https://claude.ai/code/session_01AtmUVnQwZfjDBuUzF7TdGh
The test created a HistoryManager backed by a real file but never
stopped its HistorySavingThread. The thread briefly holds a strong
reference to the manager inside its polling loop, so the instance
could survive the gc.collect() in the hmmax fixture teardown,
making the instance-leak assertion fail intermittently.

Stop the saving thread and close the database like the other tests
in this file do, and drop the unreachable `HistoryManager.__max_inst`
assignment that name-mangling never applied anyway.

Fixes #15161

https://claude.ai/code/session_01AtmUVnQwZfjDBuUzF7TdGh
Honor PEP 263 coding cookies when reading module sources for the
autoreload diffing logic, the way the import system does, instead of
assuming utf-8. Sources that declare another encoding were read as
empty (the UnicodeDecodeError is caught and logged), disabling
hot-patching for those modules, and the logged traceback was noisy on
the first %load_ext autoreload.

The regression test fails with the previous explicit utf-8 reading.

Closes #15193 (the original cp1252 crash reported there was already
fixed by reading with an explicit encoding, this handles the
remaining non-utf-8 sources).

https://claude.ai/code/session_01AtmUVnQwZfjDBuUzF7TdGh
inspect_object is not called anywhere in IPython anymore, so
registering handlers on it has no effect, and a search of public
repositories found no external users (unlike complete_object, which
pyflyby, riptable and maiev register completers on, and which is
unchanged).

Emit a DeprecationWarning through a module __getattr__ so that simply
importing the name warns, which also covers consumers that only call
.register().

First step towards #15068.

https://claude.ai/code/session_01AtmUVnQwZfjDBuUzF7TdGh
xml.etree.ElementTree.ParseError is a SyntaxError subclass that
leaves .text set to None; IPython 9.6.0 raised an AssertionError in
ListTB._format_exception_only when rendering it. The guard was added
as part of #15012, but without a test; this locks the behavior in.

The test fails if the None check in _format_exception_only is
removed.

Closes #15024

https://claude.ai/code/session_01AtmUVnQwZfjDBuUzF7TdGh
@Carreau Carreau merged commit 6a7c160 into main Jun 13, 2026
27 checks passed
@Carreau Carreau added this to the 9.15 milestone Jun 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants