Skip to content

PyREPL: Different Completion Behavior with GNU Readline #145392

Closed as not planned
Closed as not planned

Description

@tanloong

Bug report

Bug description:

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'.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

Activity

  1. added
    stdlibStandard Library Python modules in the Lib/ directory
    topic-replRelated to the interactive shell
    on Mar 1, 2026
  2. changed the title [-]PyREPL: Different Completion Behavior Between with GNU Readline[/-] [+]PyREPL: Different Completion Behavior with GNU Readline[/+] on Mar 5, 2026
  3. encukou commented on Apr 1, 2026

    @encukou
    Member

    Do you have a reproducer?
    Is this needed/helpful for SQLite?

  4. tanloong commented on Apr 1, 2026

    @tanloong
    ContributorAuthor

    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.

  5. tanloong commented on Apr 1, 2026

    @tanloong
    ContributorAuthor

    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.mp4
  6. encukou commented on Apr 7, 2026

    @encukou
    Member

    Thanks! That makes sense.

    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.

    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.

  7. added
    type-featureA feature request or enhancement
    and removed
    type-bugAn unexpected behavior, bug, or error
    on Apr 8, 2026
  8. encukou commented on Apr 8, 2026

    @encukou
    Member

    I'll close for now; let's reopen when this becomes helpful.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-replRelated to the interactive shelltype-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions