`input` assumes the last character is a '\n' and always strips it
Open
Nobody has claimed this yet.
interpreter-core
type-bug
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
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
- gh-149237
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the provided ./python -c input command, then inspect CPython's builtin input implementation and linked PR gh-149237. Done means tty input no longer loses the final character when the read data does not end with a newline, with the relevant tests passing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli, operating-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100