Skip to content

Replace ctypes based Windows console calls in _pyrepl #150582

Open

Description

@aisk

My preference is still that we ought to be actively migrating from ctypes to a proper native module for these. Performance and reliability will thank us.

Originally posted by @zooba in #132888

  • GetStdHandle (already exist in _winapi)
  • WaitForSingleObject (already exist in _winapi)
  • GetConsoleMode
  • SetConsoleMode
  • GetConsoleScreenBufferInfo
  • ScrollConsoleScreenBufferW
  • ReadConsoleInputW
  • FlushConsoleInputBuffer

Linked PRs

Activity

  1. added
    type-refactorCode refactoring (with no changes in behavior)
    topic-replRelated to the interactive shell
    on May 29, 2026
  2. added
    stdlibStandard Library Python modules in the Lib/ directory
    on May 29, 2026
  3. chris-eibl commented on Sep 11, 2026

    @chris-eibl
    Member

    @zooba I assume the things not yet in _winapi are fine to put in there?

  4. zooba commented on Sep 11, 2026

    @zooba
    Member

    I assume the things not yet in _winapi are fine to put in there?

    Strictly speaking, yes, but if the module already has big chunks of Windows-specific functions that use those APIs, it's probably better (and likely easier) to just move the entire function into C.

    I'm fine for a couple of higher-level functions to go into _winapi with comments that it should be moved to a REPL native module when one exists. Start their names with _pyrepl_... and there'll be no controversy.

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

    OS-windowsstdlibStandard Library Python modules in the Lib/ directorytopic-replRelated to the interactive shelltype-refactorCode refactoring (with no changes in behavior)

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions