Repository navigation
test_pyrepl.test_no_newline() failure on main #143394
Copy link
Copy link
Closed
Labels
3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixestestsTests in the Lib/test dirTests in the Lib/test dirtopic-replRelated to the interactive shellRelated to the interactive shelltype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
test_pyrepl started failing for me a day or two ago. According to git bisect, this is the problematic commit:
8a2deea1fc725f8147254f87c6042fcf75a1d03b is the first bad commit
commit 8a2deea1fc725f8147254f87c6042fcf75a1d03b
Author: Jan-Eric Nitschke <47750513+JanEricNitschke@users.noreply.github.com>
Date: Fri Jan 2 14:04:37 2026 +0100
gh-128067: Fix pyrepl overriding printed output without newlines (#138732)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Lib/_pyrepl/unix_console.py | 7 +++---
Lib/_pyrepl/windows_console.py | 7 +++---
Lib/test/test_pyrepl/test_pyrepl.py | 38 +++++++++++++++++++++++++++++++
Lib/test/test_pyrepl/test_unix_console.py | 14 ++++++++++++
Lib/test/test_pyrepl/test_windows_console.py | 14 ++++++++++++
Misc/ACKS | 1 +
.../next/Windows/2025-09-14-13-35-44.gh-issue-128067.BGdP_A.rst | 1 +
7 files changed, 76 insertions(+), 6 deletions(-)
create mode 100644 Misc/NEWS.d/next/Windows/2025-09-14-13-35-44.gh-issue-128067.BGdP_A.rst
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
Linked PRs
- gh-143394: filter for turning off automatic margins in test_no_newline #143433
- [3.14] gh-143394: filter for turning off automatic margins in test_no_newline (GH-143433) #143459
- gh-143394: On macOS, run main PyREPL tests as "Apple Terminal" as well #143461
- [3.14] gh-143394: On macOS, run main PyREPL tests as "Apple Terminal" as well (GH-143461) #143466
- [3.13] gh-143394: On macOS, run main PyREPL tests as "Apple Terminal" as well (GH-143461) #143467
- [3.13] gh-143394: filter for turning off automatic margins in test_no_newline (GH-143433) #143478
- gh-143394: Skip pyrepl test_no_newline() basic REPL if readline is missing #147973
- [3.14] gh-143394: Skip pyrepl test_no_newline() basic REPL if readline is missing (GH-147973) #148005
- [3.13] gh-143394: Skip pyrepl test_no_newline() basic REPL if readline is missing (GH-147973) #148006
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixestestsTests in the Lib/test dirTests in the Lib/test dirtopic-replRelated to the interactive shellRelated to the interactive shelltype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Activity
johnslavik commentedon Jan 3, 2026
What are the failures you're seeing exactly? Which tests are failing exactly? @ZeroIntensity
topic-replpending(I'd skip any other labels because we don't have enough information)smontanaro commentedon Jan 3, 2026
Sorry, forgot the key bit.
johnslavik commentedon Jan 3, 2026
Notes:
cleaned_outputcontained unexpected ANSI sequences, free-threaded build (unlikely to be related).smontanaro commentedon Jan 3, 2026
Failing on 3.14 branch as well.
johnslavik commentedon Jan 3, 2026
For the passing case,
cleaned_outputends withFor the OP's case,
cleaned_outputends withThe presence of
\x1b[?7lprevented the test from passing.johnslavik commentedon Jan 3, 2026
As noted, this is related to GH-138732. CC @JanEricNitschke @chris-eibl
@ambv, this looks similar to the builbot failure from GH-138732 where
\x1b[34hpopped up. However, this issue appeared on MacOS and the sequence was\x1b[?7l.Not sure whether this is
testsorstdlib-- auto-wrap mode from?7hand?7lmay technically change the visual output and cursor position. Please confirm me on that though.@ZeroIntensity
3.133.143.15(andtopic-replof course)chris-eibl commentedon Jan 4, 2026
test_no_newlineneeds a lot of filtering, and that's why I suggested two easier tests additionally. Łukasz already hardenedtest_no_newlinein #143356.We can try to filter for
\x1b[?7las well, but iftest_no_newlinegets a maintenance burden, IMHO we can just remove it, too?chris-eibl commentedon Jan 4, 2026
@smontanaro does adding
fix the issue for you?
johnslavik commentedon Jan 4, 2026
If that's the case, let's relabel this as
tests@picnixz (notstdlib)24 remaining items
pythongh-143394: filter for turning off automatic margins in test_no_…
pythongh-143394: On macOS, run main PyREPL tests as "Apple Terminal" …
furkanonder commentedon Mar 29, 2026
The test is only passing when the GNU readline is enabled in the CPython build.
Why readline matters
The test sends both commands at once via
os.write(master_fd, b"print('Something pretty long', end='')\nexit()\n")to a PTY master.With readline: readline puts the terminal in raw mode (
ECHO=off) because it handles character echoing itself.With kernel
ECHOdisabled, input written to the PTY master is not echoed back into the read stream. The outputis clean – just the REPL's own output - and
"Something pretty long>>> exit()"is found.Without readline: the basic REPL falls back to plain C
fgets(), which doesn't touch terminal settings. Thekernel's
ECHOflag stays on, so every byte written to the PTY master is immediately echoed back into the read stream.Both commands (
print(…)\r\nexit()\r\n) are echoed as a block before the REPL processes anything.exit()appearsearly in this echo block, never after
>>>, and the assertion fails.How I confirmed this
I wrote a diagnostic script debug_pyrepl_issue.py that checks whether the REPL toggles the
ECHOtermios flag (indicating readline is active) and then reproduces the test scenario.Example output on a machine without readline:
Example output on a machine with readline:
This is directly visible in the buildbot configure logs:
checking for stdlib extension module readline... yeschecking for stdlib extension module readline... missingvstinner commentedon Apr 1, 2026
On Linux, I confirm that
test_pyreplpass with thereadlinemodule, and fails without thereadlinemodule (ex: runfind -name "readline*so" -deletein the Python source tree).pythongh-143394: Skip pyrepl test_no_newline() basic REPL if readline…
vstinner commentedon Apr 1, 2026
I wrote #147973 to skip the test on the basic REPL if the readline module is missing.
gh-143394: Skip pyrepl test_no_newline() basic REPL if readline is mi…
pythongh-143394: Skip pyrepl test_no_newline() basic REPL if readline…
pythongh-143394: Skip pyrepl test_no_newline() basic REPL if readline…
vstinner commentedon Apr 2, 2026
The latest known test_no_newline() failure should be fixed by 97babb8 (backport to 3.13 and 3.14 will follow once the CI pass on the PRs). I close the issue.
[3.13] gh-143394: Skip pyrepl test_no_newline() basic REPL if readlin…
smontanaro commentedon Apr 3, 2026
Thanks @vstinner. Fixed for me, even on my very pokey Raspberry Pi (which I only test on "for fun").
[3.14] gh-143394: Skip pyrepl test_no_newline() basic REPL if readlin…
pythongh-143394: Skip pyrepl test_no_newline() basic REPL if readline…