Skip to content

Multi-line input prompt mishandled in REPL #142078

@tathyagarg

Description

@tathyagarg

Bug report

Bug description:

>>> input("a\nb: ")
a
a
a
a
a
a
a
a
b: 1111111
'1111111'

When the input prompt has 1 or more newline characters, the text preceding the last \n is printed again when a character is typed in by the user. Every subsequent character typed in by the user after the second also leads to text preceding the last \n to be reprinted. (i.e., 2 characters inputted -> prompt repeated 1 time, 3 characters inputted -> prompt repeated 2 times, etc.)

This does not occur on 3.12, only 3.13+, and only on the REPL, not when running a script.

A similar issue also occurs when using \t in the input prompt:

>>> input("a\t:")
a	a	:b
'b'

This is slightly different from the newline case - the text is repeated only once regardless of the number of characters in the input.

Screen.Recording.2025-11-29.at.1.54.19.PM.mov

CPython versions tested on:

3.13, 3.14

Operating systems tested on:

macOS, Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-replRelated to the interactive shelltype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions