Skip to content

input assumes the last character is a '\n' and always strips it #149495

@Virv12

Description

@Virv12

Bug report

Bug description:

When reading from the tty python's builtin input function assumes that the last character read is a newline and proceed to strip it out leading to missing input.

Current behaviour:

$ ./python -c 'print(repr(input()))'
abc'ab'

Expected behaviour:

$ ./python -c 'print(repr(input()))'
abc'abc'

CPython versions tested on:

3.14, 3.13, CPython main branch

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions