The current completion logic in Lib/_pyrepl/completing_reader.py uses a suffix-insertion strategy (source code):
In the contrast, Readline completely replaces user input with the candidate (source code).
This will lead to unwanted behavior in case-insensitive completion scenario. If user input 'xy', they might get 'xyZZY' instead of the expected 'XYZZY'.
changed the title [-]PyREPL: Different Completion Behavior Between with GNU Readline[/-][+]PyREPL: Different Completion Behavior with GNU Readline[/+]on Mar 5, 2026
After seeing #145379, I wondered if the SQLite CLI could also use PyREPL. That would greatly improve the experience on Windows. I had an LLM create a quick demo of the SQLite CLI using PyREPL.
In that demo, when I type sel and press Tab, it completes to selECT instead of the correct SELECT.
I will push the demo branch as a reproducer soon.
The demo is far from ready-to-use, and there are also syntax highlighting issues (maybe could not solved until #141619 is merged). But I believe the SQLite CLI will eventually move to PyREPL (we might not need to modify the sqlite module directly but instead update the underlying code module to use PyREPL). Changing the completion to use a replace-strategy instead of suffix-insertion will help with this. I'm fine with pausing this issue until the SQLite CLI moves to PyREPL, and then treat it as a SQLite bug only after that.
Activity
encukou commented on Apr 1, 2026
Do you have a reproducer?
Is this needed/helpful for SQLite?
tanloong commented on Apr 1, 2026
Yes, this will be helpful for SQLite.
After seeing #145379, I wondered if the SQLite CLI could also use PyREPL. That would greatly improve the experience on Windows. I had an LLM create a quick demo of the SQLite CLI using PyREPL.
In that demo, when I type sel and press Tab, it completes to selECT instead of the correct SELECT.
I will push the demo branch as a reproducer soon.
The demo is far from ready-to-use, and there are also syntax highlighting issues (maybe could not solved until #141619 is merged). But I believe the SQLite CLI will eventually move to PyREPL (we might not need to modify the sqlite module directly but instead update the underlying code module to use PyREPL). Changing the completion to use a replace-strategy instead of suffix-insertion will help with this. I'm fine with pausing this issue until the SQLite CLI moves to PyREPL, and then treat it as a SQLite bug only after that.
tanloong commented on Apr 1, 2026
This is the demo branch as a reproducer: https://github.com/tanloong/cpython/tree/sqlite-pyrepl
In the screen recording, when typing sel and press Tab, it completes to selECT instead of SELECT.
simplescreenrecorder-2026-04-01_21.46.35.mp4encukou commented on Apr 7, 2026
Thanks! That makes sense.
Let's do that. There is no issue in current use of pyrepl, and if sqlite3 starts using it, it'll only be a small inconvenience.
encukou commented on Apr 8, 2026
I'll close for now; let's reopen when this becomes helpful.