Skip to content

[Windows] Python 3.13 New REPL prompt swallows characters with print(..., end=" ") #128067

Closed

Description

@cessor

Bug report

Bug description:

I encountered the following unexpected behavior when working with the new REPL on Windows 10's cmd just now:

Actual Behavior

>>> for i in range(0, 14, 2):
...     print(i, end=" ")
...
>>> 4 6 8 10 12
  • When I use print and pass an argument to the end-parameter, the resulting line is missing 4 characters.
  • The four chars of the REPL prompt >>> appear to write over the line, as the cursor blinks on the first visible position (indicator sits under the number 4)
  • Typing overwrites the shown chars.

Expected Behavior

>>> for i in range(0, 14, 2):
...     print(i, end=" ")
...
0 2 4 6 8 10 12 >>> _
  • REPL on Python 3.12 works as expected.
  • Results are printed in one line, prompt appears at the end, cursor follows at end of line.

Note:

This works as expected:

>>> for i in range(0, 14, 2):
...     print(i)
...
0
2
4
6
8
10
12

CPython versions tested on:

3.13

Operating systems tested on:

Windows

Linked PRs

Activity

  1. added
    type-bugAn unexpected behavior, bug, or error
    on Dec 18, 2024
  2. added
    stdlibStandard Library Python modules in the Lib/ directory
    3.13only security fixes
    3.14bugs and security fixes
    on Dec 20, 2024
  3. devdanzin commented on Dec 23, 2024

    @devdanzin
    Member

    Confirmed on main:

    >>> print(10, end=' ')
    >>>

    It's possible to see the 10 output appear then be overwritten by the prompt. Any string ending without a newline seems to suffer from this:

    >>> print("a\n", 10, end=' ')
    a
  4. devdanzin commented on Dec 24, 2024

    @devdanzin
    Member

    It's possible to capture output in a StringIO in code.InteractiveInterpreter.runcode and add a \n character if the output doesn't end in a newline. It should change the behavior to (in both Windows and Linux):

    >>> for i in range(0, 14, 2):
    ...     print(i, end=" ")
    ...
    0 2 4 6 8 10 12 
    >>> _

    That is, the prompt would always appear on a new line.

    If this is considered a good solution, I can submit a PR.

    Edit: with a PoC change, the issue is resolved and test_pyrepl, test_repl and test_code pass.

  5. devdanzin commented on Dec 24, 2024

    @devdanzin
    Member

    The proposed fix changes two behaviors that could be considered bugs in how output is handled.

    Without the change, in Windows, printing a very long line ending with a space would result in its last wrapped line being overwritten by the prompt and further input:

    >>> print("abcdef" * 30, end=' ')
    abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef
    >>> efabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef

    While on Linux, without the change, the prompt appears right at the end of the long line:

    >>> print("abcdef" * 30, end=' ')
    abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef
    abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef >>>

    With the change, the prompt always appears on a new line.

  6. JanEricNitschke commented on Sep 9, 2025

    @JanEricNitschke
    Contributor

    @devdanzin Are you still having a look at this or can i try to give it a go?

  7. 23 remaining items

  8. added a commit that references this issue on Jan 2, 2026
  9. added 2 commits that reference this issue on Jan 2, 2026
  10. added 6 commits that reference this issue on Jan 2, 2026
  11. ambv commented on Jan 2, 2026

    @ambv
    Contributor

    Fixed! Thanks for your contribution.

  12. amirihekmatallah-code commented on Jan 28, 2026

    @amirihekmatallah-code
  13. amirihekmatallah-code commented on Jan 28, 2026

    @amirihekmatallah-code
  14. added 2 commits that reference this issue on Feb 15, 2026
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

    3.13only security fixes3.14bugs and security fixes3.15bugs and security fixesOS-windowsstdlibStandard 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