summaryrefslogtreecommitdiffstats
path: root/Lib/_pyrepl
Commit message (Collapse)AuthorAgeFilesLines
* Fix while statements with non-bool conditions in `_pyrepl` (#127509)RUANG (James Roy)2025-01-012-2/+2
| | | Fix non-bool value conditions
* gh-122273: Support PyREPL history on Windows (#127141)Victor Stinner2024-11-261-1/+3
| | | Co-authored-by: devdanzin <74280297+devdanzin@users.noreply.github.com>
* gh-126456: Fix _pyrepl curses tigetstr() (#126472)Victor Stinner2024-11-131-2/+2
|
* gh-124960: Fixed `barry_as_FLUFL` future flag does not work in new REPL ↵Wulian2024-10-141-2/+8
| | | | | | (#124999) Co-authored-by: Nice Zombies <nineteendo19d0@gmail.com> Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* gh-124628: Pyrepl inputs on Windows shouldn't always be blocking reads (#124629)Dino Viehland2024-09-261-9/+21
|
* gh-123856: Fix PyREPL failure when a keyboard interrupt is triggered after ↵Emily Morehouse2024-09-251-5/+6
| | | | | using a history search (#124396) Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* Support the "pager" binary in _pyrepl (#122878)Stefano Rivera2024-09-191-0/+2
| | | | | | | | | Debian (and derivatives) provide a /usr/bin/pager binary, managed by the alternatives system, that always points to an available pager utility. Allow _pyrepl to use it, to follow system policy. This is a very trivial change, from a patch that Debian has been carrying since 2.7 era. Seems appropriate to upstream. https://bugs.debian.org/799555
* gh-124027: Support Del, PgUp, and PgDn on TERM=vt100 (#124028)Miro Hrončok2024-09-132-0/+3
| | | | | | | | | | | pyrepl: Support Del, PgUp, and PgDn on TERM=vt100 From Fedora's /etc/inputrc: "\e[5~": history-search-backward "\e[6~": history-search-forward "\e[3~": delete-char Fixes https://github.com/python/cpython/issues/124027
* gh-120221: Support KeyboardInterrupt in asyncio REPL (#123795)Łukasz Langa2024-09-064-17/+116
| | | | | | | | | This switches the main pyrepl event loop to always be non-blocking so that it can listen to incoming interruptions from other threads. This also resolves invalid display of exceptions from other threads (gh-123178). This also fixes freezes with pasting and an active input hook.
* gh-119310: Fix encoding when reading old history file (#121779)aorcajo2024-09-061-4/+8
| | | Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* gh-119034, REPL: Change page up/down keys to search in history (#123607)Victor Stinner2024-09-063-4/+72
| | | | | | Change <page up> and <page down> keys of the Python REPL to history search forward/backward. Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* gh-111201: fix auto-indent in pyrepl for muliple pound comments (#123196)Arnon Yaari2024-09-061-1/+1
|
* gh-123240: Raise input audit events in the new REPL (#123274)sobolevn2024-09-051-2/+6
|
* gh-123572: Fix key codes in VK_MAP in windows_console.py (#122692)devdanzin2024-09-031-4/+5
|
* gh-123177: Fix prompt for wrapped lines in pyrepl (#123324)Matt Wozniski2024-08-251-1/+9
| | | | | | | When display lines above the cursor come from the cache, the first line to not come from the cache may be a wrapped line, starting half way through a logical line in the buffer. Detect and handle this case to avoid accidentally drawing a stray prompt in the middle of a logical line.
* gh-123177: Deactivate line wrap for Apple Terminal via scape codes in the ↵Pablo Galindo Salgado2024-08-251-0/+8
| | | | new REPL (#123267)
* gh-123228: fix return type for _ReadlineWrapper.get_line_buffer() (#123281)Sergey B Kirpichev2024-08-241-4/+3
| | | Co-authored-by: Carl Friedrich Bolz-Tereick <cfbolz@gmx.de>
* gh-122546: use same filename for different exceptions in new repl (#123217)Sergey B Kirpichev2024-08-221-1/+1
| | | | | * gh-122546: use same filename for different exceptions in new repl * +1
* gh-123149: Suppress verbose repr in new REPL (#123151)James2024-08-191-2/+2
|
* gh-121804: Always show error location for SyntaxError's in new repl (#121886)Sergey B Kirpichev2024-08-191-3/+6
|
* gh-82378 fix sys.tracebacklimit in pyrepl, approach 2 (#123062)CF Bolz-Tereick2024-08-181-5/+7
| | | | Make sure that pyrepl uses the same logic for sys.tracebacklimit as both the basic repl and the standard sys.excepthook
* Fix typos in comments and test code (#122846)Xie Yanbo2024-08-123-4/+4
|
* gh-119896: Fix CTRL-Z behavior in the new REPL on Windows (GH-122217)Dino Viehland2024-07-304-4/+14
|
* gh-121957: Emit audit events for `python -i` and `python -m asyncio` (GH-121958)Łukasz Langa2024-07-221-0/+2
| | | | Relatedly, emit the `cpython.run_startup` event from the Python version of `PYTHONSTARTUP` handling.
* gh-120678: pyrepl: Include globals from modules passed with `-i` (GH-120904)Alex Waygood2024-07-171-0/+3
| | | Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* gh-121295: Fix blocked console after interrupting a long paste (GH-121815)Marta Gómez Macías2024-07-151-1/+9
|
* gh-121610: pyrepl - handle extending blocks when multi-statement blocks are ↵saucoide2024-07-151-10/+21
| | | | | | | | | | | | pasted (GH-121757) console.compile with the "single" param throws an exception when there are multiple statements, never allowing to adding newlines to a pasted code block (gh-121610) This add a few extra checks to allow extending when in an indented block, and tests for a few examples Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* gh-121790: Fix interactive console initialization (#121793)Milan Oberkirch2024-07-153-16/+12
| | | Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* gh-121245: Refactor site.register_readline() (GH-121659)Sergey B Kirpichev2024-07-151-23/+23
| | | Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* gh-121746: Bind Alt+Enter to "accept" in the REPL (GH-121754)Rodrigo Girão Serrão2024-07-151-1/+1
|
* gh-121499: Fix multi-line history rendering in the REPL (#121531)Pablo Galindo Salgado2024-07-132-0/+7
| | | Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
* gh-121609: Fix pasting of characters containing unicode character joiner ↵Marta Gómez Macías2024-07-131-1/+0
| | | | (#121667)
* gh-121497: Make Pyrepl respect correctly the history with input hook set ↵Pablo Galindo Salgado2024-07-131-2/+2
| | | | (#121498)
* gh-118908: Use __main__ for the default PyREPL namespace (#121054)Łukasz Langa2024-06-263-61/+58
|
* gh-120417: Remove unused imports in the stdlib (#120420)Victor Stinner2024-06-124-6/+2
|
* gh-118908: Fix completions after namespace change in REPL (#120370)Lysandros Nikolaou2024-06-122-5/+12
|
* gh-120221: Deliver real singals on Ctrl-C and Ctrl-Z in the new REPL (#120354)Pablo Galindo Salgado2024-06-111-4/+4
|
* gh-118908: Limit exposed globals from internal imports and definitions on ↵Eugene Triguba2024-06-111-3/+18
| | | | new REPL startup (#119547)
* gh-119517: Fixes for pasting in pyrepl (#120253)Matt Wozniski2024-06-116-57/+134
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Remove pyrepl's optimization for self-insert This will be replaced by a less specialized optimization. * Use line-buffering when pyrepl echoes pastes Previously echoing was totally suppressed until the entire command had been pasted and the terminal ended paste mode, but this gives the user no feedback to indicate that an operation is in progress. Drawing something to the screen once per line strikes a balance between perceived responsiveness and performance. * Remove dead code from pyrepl `msg_at_bottom` is always true. * Speed up pyrepl's screen rendering computation The Reader in pyrepl doesn't hold a complete representation of the screen area being drawn as persistent state. Instead, it recomputes it, on each keypress. This is fast enough for a few hundred bytes, but incredibly slow as the input buffer grows into the kilobytes (likely because of pasting). Rather than making some expensive and expansive changes to the repl's internal representation of the screen, add some caching: remember some data from one refresh to the next about what was drawn to the screen and, if we don't find anything that has invalidated the results that were computed last time around, reuse them. To keep this caching as simple as possible, all we'll do is look for lines in the buffer that were above the cursor the last time we were asked to update the screen, and that are still above the cursor now. We assume that nothing can affect a line that comes before both the old and new cursor location without us being informed. Based on this assumption, we can reuse old lines, which drastically speeds up the overwhelmingly common case where the user is typing near the end of the buffer. * Speed up pyrepl prompt drawing Cache the `can_colorize()` call rather than repeatedly recomputing it. This call looks up an environment variable, and is called once per character typed at the REPL. The environment variable lookup shows up as a hot spot when profiling, and we don't expect this to change while the REPL is running. * Speed up pasting multiple lines into the REPL Previously, we were checking whether the command should be accepted each time a line break was encountered, but that's not the expected behavior. In bracketed paste mode, we expect everything pasted to be part of a single block of code, and encountering a newline shouldn't behave like a user pressing <Enter> to execute a command. The user should always have a chance to review the pasted command before running it. * Use a read buffer for input in pyrepl Previously we were reading one byte at a time, which causes much slower IO than necessary. Instead, read in chunks, processing previously read data before asking for more. * Optimize finding width of a single character `wlen` finds the width of a multi-character string by adding up the width of each character, and then subtracting the width of any escape sequences. It's often called for single character strings, however, which can't possibly contain escape sequences. Optimize for that case. * Optimize disp_str for ASCII characters Since every ASCII character is known to display as single width, we can avoid not only the Unicode data lookup in `disp_str` but also the one hidden in `str_width` for them. * Speed up cursor movements in long pyrepl commands When the current pyrepl command buffer contains many lines, scrolling up becomes slow. We have optimizations in place to reuse lines above the cursor position from one refresh to the next, but don't currently try to reuse lines below the cursor position in the same way, so we wind up with quadratic behavior where all lines of the buffer below the cursor are recomputed each time the cursor moves up another line. Optimize this by only computing one screen's worth of lines beyond the cursor position. Any lines beyond that can't possibly be shown by the console, and bounding this makes scrolling up have linear time complexity instead. --------- Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net> Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
* gh-119553: Fix console when pressing Ctrl-C within a multiline block (#120075)Lysandros Nikolaou2024-06-042-1/+3
|
* gh-119842: Honor PyOS_InputHook in the new REPL (GH-119843)Pablo Galindo Salgado2024-06-044-10/+56
| | | | | Signed-off-by: Pablo Galindo <pablogsal@gmail.com> Co-authored-by: Łukasz Langa <lukasz@langa.pl> Co-authored-by: Michael Droettboom <mdboom@gmail.com>
* gh-119553: Clear reader on Ctrl-C command (GH-119801)Lysandros Nikolaou2024-06-041-0/+1
|
* gh-120041: Refactor check for visible completion menu in completing_reader ↵Lysandros Nikolaou2024-06-042-6/+4
| | | | (#120055)
* gh-120041: Do not use append_to_screen when completions are visible (GH-120042)Lysandros Nikolaou2024-06-042-9/+18
|
* gh-118835: pyrepl: Fix prompt length computation for custom prompts ↵Daniel Hollas2024-06-031-2/+8
| | | | containing ANSI escape codes (#119942)
* gh-118894: Make asyncio REPL use pyrepl (GH-119433)Łukasz Langa2024-05-314-46/+70
|
* gh-111201: Improve pyrepl auto indentation (#119606)Arnon Yaari2024-05-311-8/+19
| | | | - auto-indent when editing multi-line block - ignore comments
* gh-111201: Support pyrepl on Windows (#119559)Dino Viehland2024-05-317-30/+654
| | | | Co-authored-by: Anthony Shaw <anthony.p.shaw@gmail.com> Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* gh-119555: catch SyntaxError from compile() in the InteractiveColoredConsole ↵Sergey B Kirpichev2024-05-291-1/+1
| | | | (#119557)
* gh-119443: Turn off from __future__ import annotations in REPL (#119493)Jelle Zijlstra2024-05-291-1/+1
|