167 Commits
Author SHA1 Message Date
An Long 2468c35c3b gh-150582: Use _winapi for _pyrepl console handles and waits (#150584) 2026-10-25 10:11:43 +00:00
dec26cefe4 gh-130698: Convert sys.ps1 and sys.ps2 to strings before PyREPL use (#158828)
Co-authored-by: Brett Cannon <brett@python.org>
Co-authored-by: Stan Ulbrych <stan@python.org>
2026-10-23 23:38:52 +00:00
Loïc SimonandLukasz Langa fdee11f099 gh-69605: PyREPL: insert "import" after "from foo <tab>" (#148445)
Improve _pyrepl._module_completer.ModuleCompleter.get_completions:
  * "from x.y.z " [tab]-> "from x.y.z import "
  * "from foo"    [tab]-> "from foo "          [tab]-> "from foo import"
    (if only one suggestion)

Co-authored-by: Lukasz Langa <ambv@meta.com>
2026-10-21 03:14:55 -07:00
Loïc Simon 488ce0f050 gh-69605: fix PyREPL completions inserted for import statements with spaces (#148629)
Fix `from math .<tab>` inserting `from math .ath.integer` instead of `from math.integer`
2026-10-20 16:23:13 -07:00
Bartosz Sławecki f5bd07700e gh-148228: Enable error overlays in the REPL (GH-148229) 2026-10-20 11:55:45 -07:00
6f92424d8e gh-159225: PyREPL input should not write to history (#159263)
* gh-159225: PyREPL input should not write to history

Values entered in an input statement are not Python statements and thus the reader should suspend history recording when in input mode

* 📜🤖 Added by blurb_it.

* Remove comment

* Only suspend writing

* gh-159225: Cover input history isolation and interrupted reads

---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2026-10-13 19:41:01 +01:00
Harjoth KharaandClaude Fable 5 46ee3580c0 gh-152907: Restore cooked output flags around the input hook in the new REPL (#153389)
* gh-152907: Restore cooked output flags around the input hook in the new REPL

pyrepl clears OPOST for its own cursor rendering but calls PyOS_InputHook
from inside the raw-mode read loop, so output written by an input hook
(GUI toolkit event loops, and any warning/traceback/print they emit) is
emitted with bare '\n' and no '\r'.  Restore the terminal's saved output
flags around the hook call and re-enter raw mode afterwards; only oflag is
toggled so ECHO/ICANON stay off at the prompt.

* Skip the input-hook test on platforms without pty devices

The Emscripten buildbot has the pty module but no pty devices, so
pty.openpty() raises OSError("out of pty devices").  Guard the test
class the same way Lib/test/test_pty.py does.

* Propagate the input hook's return value and drop the sleep from the test

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Trim comments

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Observe the hook's output synchronously instead of via the reader thread

The reader thread no longer feeds any assertion: the hook drains the pty
master itself, so the check is an exact comparison. A drainer is still
needed for restore(), which writes before switching modes.

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-09-24 17:01:19 +01:00
4bc392c134 gh-69919: Catch all compile errors in the code module, pyrepl and IDLE (GH-157585)
compile() can raise MemoryError or RecursionError for too deeply
nested source, not only SyntaxError, OverflowError and ValueError.
IDLE's Shell then lost its prompt until the input was deleted.

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-23 23:04:13 +03:00
Jelle Zijlstra e2118b0ac2 gh-149985: Remove future annotations and if TYPE_CHECKING in pyrepl (#149992)
`from __future__ import annotations` is soft-deprecated now that evaluation
of annotations is always deferred. `if TYPE_CHECKING` can often be replaced
with lazy imports.
2026-08-25 16:48:54 -07:00
Bartosz Sławecki bc2fd447d2 gh-151822: Colorize commands separately in the REPL (#151823) 2026-07-18 13:17:51 +02:00
Jonathan Oberländer ff5646206f gh-147950: Additionally bind yank-arg to M-_ in pyrepl (#147949) 2026-07-18 11:56:14 +02:00
Lukas Geiger 65afd6579f gh-141968: Use take_bytes to simplify and remove copy from pyrepl BaseEventQueue (#149852) 2026-07-11 16:59:37 +01:00
832d557111 gh-152068: Reset PyREPL Colors on prompt finish (#152108)
* Use ANSI Escape Codes from Colorize

* Print ANSI Color reset on finish and restore

* 📜🤖 Added by blurb_it.

* Update imports

* Update Misc/NEWS.d/next/macOS/2026-06-24-18-00-39.gh-issue-152068.ThsmJU.rst

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>

* Remove news entry

* 📜🤖 Added by blurb_it.

* gh-152068: Test ANSI reset is emitted on console finish() and restore()

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-04 14:16:02 +01:00
Hugo van Kemenade 627adb517f gh-151428: Remove unused imports from stdlib (#151478) 2026-06-16 19:31:01 +03:00
Bartosz Sławecki a7007322c2 gh-151390: Colorize match + and match - in the REPL (#151391) 2026-06-14 19:06:30 +03:00
Bartosz Sławecki ff64d8de66 gh-145239: Colorize case + in the REPL (#150979) 2026-06-10 09:36:50 +03:00
Tomas R. ed99680487 gh-130472: Use fancycompleter in import completions (#148188) 2026-05-05 01:36:43 +00:00
Tian Gao 6b632ce36b gh-139167: Allow users to hook gen_colors function to pyrepl Reader (#141619) 2026-05-02 13:28:00 -07:00
Pablo Galindo Salgado 09968dd2a9 gh-148105: _pyrepl: switch console refresh to structured rendered screens (#146584) 2026-04-08 23:42:26 +01:00
0b20bff386 gh-146458: Fix REPL height and width tracking on resize (#146459)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2026-04-07 23:09:11 +02:00
dfeb160bc3 gh-130273: Fix traceback color output with unicode characters (GH-142529)
Account for the display width of Unicode characters so that colors and underlining in traceback output is correct.

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Victor Stinner <vstinner@python.org>
2026-04-07 15:05:23 +02:00
Pablo Galindo Salgado f8293faf37 gh-130472: Remove readline-only hacks from PyREPL completions (#148161)
PyREPL was still carrying over two readline-specific tricks from the
fancy completer: a synthetic CSI prefix to influence sorting and a fake
blank completion entry to suppress readline's prefix insertion. Those
workarounds are not appropriate in PyREPL because the reader already
owns completion ordering and menu rendering, so the fake entries leaked
into the UI as real terminal attributes and empty menu cells.

Sort completion candidates in ReadlineAlikeReader by their visible text
with stripcolor(), and let the fancy completer return only real matches.
That keeps colored completions stable without emitting bogus escape
sequences, removes the empty completion slot, and adds regression tests
for both the low-level completer output and the reader integration.
2026-04-06 14:57:25 +00:00
Loïc SimonandPablo Galindo Salgado b07becb573 gh-140870: PyREPL auto-complete module attributes in import statements (#140871)
Co-authored-by: Pablo Galindo Salgado <pablogsal@gmail.com>
2026-04-05 19:10:59 +00:00
Loïc Simon c64baff1d8 gh-69605: Add math.integer to PyREPL module completer hardcoded list (#144811) 2026-04-05 19:31:19 +01:00
Antonio CuniandPablo Galindo 1c4408aeca gh-130472: Integrate fancycompleter with the new repl, to get colored tab completions (#130473)
Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
2026-04-05 14:23:07 +00:00
Pieter Eendebak 1fd66eadd2 gh-139003: Use frozenset for module level attributes in _pyrepl.utils (#139004)
Use frozenset for module level attributes
2026-03-28 20:21:19 +00:00
Stan Ulbrych 087a5f6444 _pyrepl/pager.py: call less with --clear-screen (#146382) 2026-03-28 17:23:58 +00:00
Tan Long 982459132b gh-145394: Remove duplicated isearch_add_character in _pyrepl/historical_reader.py (#145396) 2026-03-19 16:38:01 +05:30
Tan Long e13f6dccd7 gh-140131: Fix REPL cursor position on Windows when module completion suggestion line hits console width (GH-140333) 2026-03-12 16:59:43 +01:00
46d5106cfa gh-142349: Implement PEP 810 - Explicit lazy imports (#142351)
Co-authored-by: T. Wouters <twouters@meta.com >
Co-authored-by: Brittany Reynoso <breynoso@meta.com>
Co-authored-by: Dino Viehland <dinoviehland@meta.com>
2026-02-12 00:15:33 +00:00
AN Long 3abc03c808 gh-132888: Fix Windows API error checking in pyrepl.windows_console (#144248) 2026-02-03 13:25:29 +01:00
Loïc SimonandTomas R. bfac54d861 gh-69605: Check for already imported modules in PyREPL module completion (GH-139461)
Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
2026-01-05 16:18:54 +01:00
Olga MatoulaandŁukasz Langa 2c39b9d2f2 gh-136924: Suspend REPL colorizing when in a REPL interactive command (GH-136926)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2026-01-03 14:35:34 +01:00
Chris EiblandŁukasz Langa ef6f92a2a6 gh-139262: Prevent swallowing REPL input on Windows (GH-139263)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2026-01-02 16:17:45 +01:00
Jan-Eric NitschkeandŁukasz Langa 8a2deea1fc gh-128067: Fix pyrepl overriding printed output without newlines (#138732)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2026-01-02 14:04:37 +01:00
yihong ecb901dd87 Drop three unused imports (#141875) 2025-11-23 16:33:05 +00:00
Tan Long 713edbcebf gh-141415: Remove unused variables and comment in _pyrepl.windows_console.py (#141416) 2025-11-11 14:27:21 -05:00
yihongandgrayjk 4e6dba0ef7 gh-139246: zero-width word paste can be wrong in default repl (GH-139254)
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
Co-authored-by: grayjk <grayjk@gmail.com>
2025-10-30 16:14:06 +01:00
yihong b8c8b8f1d3 gh-139391: properly handle signal.signal() in UnixConsole when called from a non-main thread (#139392) 2025-10-09 14:58:01 +00:00
DeepWzhandadam j hartz 81959a0364 gh-133400: Fixed Ctrl+D (^D) behavior in :mod:_pyrepl module (GH-133883)
Co-authored-by: adam j hartz <adam@smatz.net>
2025-10-09 16:16:48 +02:00
Łukasz Langa 2fc7004d54 gh-134466: Don't run when termios is inaccessible (GH-138911)
Without the ability to set required capabilities, the REPL cannot
function properly (syntax highlighting and multiline editing can't
work).

We refuse to work in this degraded state.
2025-09-17 12:59:49 +02:00
b9dbf6acb3 gh-135329: prevent infinite traceback loop on Ctrl-C for strace (GH-138133)
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
Co-authored-by: dura0ok <slpmcf@gmail.com>
Co-authored-by: graymon <greyschwinger@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2025-09-16 12:39:03 +02:00
Loïc SimonandŁukasz Langa 537133d2b6 gh-69605: Hardcode some stdlib submodules in PyREPL module completion (os.path, collections.abc...) (GH-138268)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2025-09-15 18:51:34 +02:00
Łukasz Langa 811acc85d5 gh-134953: Make the True/False/None check more efficient (GH-138931) 2025-09-15 18:27:37 +02:00
yihongandBénédikt Tran 8ef7735c53 gh-128636: Fix crash in PyREPL when os.environ is overwritten with an invalid value for macOS (GH-138089)
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-09-15 18:26:23 +02:00
00ll00andBénédikt Tran 26cfb17942 gh-138239: Fix incorrect highlighting of "type" in type statements in the REPL (GH-138241)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-09-15 18:21:41 +02:00
Stan UlbrychandŁukasz Langa a5b9d0b8b2 gh-134953: Expand theming for True/False/None (#135000)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2025-09-15 16:36:17 +02:00
yihong 7a3bca50e0 gh-138318, PyREPL: builtins should not be highlighted when used as attribute names (#138319) 2025-09-08 14:04:22 +01:00
ggqlq 8750e5ecfc gh-134869: Fix Ctrl+C corrupts REPL autocomplete (#134929) 2025-08-18 21:54:39 +01:00
c933a6bb32 gh-124621: Emscripten: Support pyrepl in browser (GH-136931)
Basic support for pyrepl in Emscripten. Limitations:
* requires JSPI
* no signal handling implemented

As followup work, it would be nice to implement a webworker variant
for when JSPI is not available and proper signal handling.

Because it requires JSPI, it doesn't work in Safari. Firefox requires
setting an experimental flag. All the Chromiums have full support since
May. Until we make it work without JSPI, let's keep the original web_example
around.

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Éric <merwok@netwok.org>
2025-07-22 12:13:38 +02:00