summaryrefslogtreecommitdiffstats
path: root/Lib/_pyrepl
Commit message (Collapse)AuthorAgeFilesLines
* [3.13] gh-118908: Use __main__ for the default PyREPL namespace (GH-121054) ↵Miss Islington (bot)2024-06-263-61/+58
| | | | (#121059)
* [3.13] gh-120417: Remove unused imports in the stdlib (GH-120420) (#120429)Miss Islington (bot)2024-06-124-6/+2
| | | | | | gh-120417: Remove unused imports in the stdlib (GH-120420) (cherry picked from commit 4c6d4f5cb33e48519922d635894eef356faddba2) Co-authored-by: Victor Stinner <vstinner@python.org>
* [3.13] gh-118908: Fix completions after namespace change in REPL (GH-120370) ↵Miss Islington (bot)2024-06-122-5/+12
| | | | | | | (#120392) (cherry picked from commit 02e74c356223feb0771759286d24d1dbac01d4ca) Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
* [3.13] gh-120221: Deliver real singals on Ctrl-C and Ctrl-Z in the new REPL ↵Miss Islington (bot)2024-06-111-4/+4
| | | | (GH-120354) (#120368)
* [3.13] gh-118908: Limit exposed globals from internal imports and ↵Miss Islington (bot)2024-06-111-3/+18
| | | | definitions on new REPL startup (GH-119547) (#120362)
* [3.13] gh-119517: Fixes for pasting in pyrepl (GH-120253) (#120353)Miss Islington (bot)2024-06-116-57/+134
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | gh-119517: Fixes for pasting in pyrepl (GH-120253) * 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. --------- (cherry picked from commit 32a0faba439b239d7b0c242c1e3cd2025c52b8cf) Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net> Co-authored-by: Matt Wozniski <mwozniski@bloomberg.net> Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
* [3.13] gh-119553: Fix console when pressing Ctrl-C within a multiline block ↵Miss Islington (bot)2024-06-042-1/+3
| | | | | | | (GH-120075) (#120076) (cherry picked from commit 69b3e8ea569faabccd74036e3d0e5ec7c0c62a20) Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
* [3.13] gh-119842: Honor PyOS_InputHook in the new REPL (GH-119843) (GH-120066)Łukasz Langa2024-06-044-10/+56
| | | | | | | (cherry picked from commit d9095194dde27eaabfc0b86a11989cdb9a2acfe1) Signed-off-by: Pablo Galindo <pablogsal@gmail.com> Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com> Co-authored-by: Michael Droettboom <mdboom@gmail.com>
* [3.13] gh-119553: Clear reader on Ctrl-C command (GH-119801) (#120062)Miss Islington (bot)2024-06-041-0/+1
| | | | | | (cherry picked from commit 010ea93b2b888149561becefeee90826bf8a2934) Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com> Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* [3.13] gh-120041: Do not use append_to_screen when completions are visible ↵Miss Islington (bot)2024-06-041-8/+15
| | | | | | | | | | | | (GH-120042) (#120051) * gh-120041: Do not use append_to_screen when completions are visible (GH-120042) (cherry picked from commit 8fc7653766b106bdbc4ff6154e0020aea4ab15e6) * gh-120041: Refactor check for visible completion menu in completing_reader (GH-120055) (cherry picked from commit bf8e5e53d0c359a1f9c285d855e7a5e9b6d91375) --------- Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
* [3.13] gh-118835: pyrepl: Fix prompt length computation for custom prompts ↵Miss Islington (bot)2024-06-031-2/+8
| | | | | | | | containing ANSI escape codes (GH-119942) (#119990) gh-118835: pyrepl: Fix prompt length computation for custom prompts containing ANSI escape codes (GH-119942) (cherry picked from commit 2e0aa731aebb8ef3d89ada82f5d39b1bbac65d1f) Co-authored-by: Daniel Hollas <daniel.hollas@bristol.ac.uk>
* [3.13] gh-118894: Make asyncio REPL use pyrepl (GH-119433) (#119884)Miss Islington (bot)2024-05-314-46/+70
| | | | | (cherry picked from commit 2237946af0981c46dc7d3886477e425ccfb37f28) Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* [3.13] gh-111201: Support pyrepl on Windows (GH-119559) (GH-119850)Miss Islington (bot)2024-05-317-30/+654
| | | | | | | | (cherry picked from commit 0d07182821fad7b95a043d006f1ce13a2d22edcb) Co-authored-by: Dino Viehland <dinoviehland@gmail.com> Co-authored-by: Anthony Shaw <anthony.p.shaw@gmail.com> Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* [3.13] gh-111201: Improve pyrepl auto indentation (GH-119606) (GH-119833)Miss Islington (bot)2024-05-311-8/+19
| | | | | | | | - auto-indent when editing multi-line block - ignore comments (cherry picked from commit dae0375bd97f3821c5db1602a0653a3c5dc53c5b) Co-authored-by: Arnon Yaari <wiggin15@yahoo.com>
* [3.13] gh-119548: Add a 'clear' command to the REPL (GH-119549) (#119552)Miss Islington (bot)2024-05-312-1/+11
| | | | | | gh-119548: Add a 'clear' command to the REPL (GH-119549) (cherry picked from commit e3bac04c37f6823cebc74d97feae0e0c25818b31) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
* [3.13] gh-119555: catch SyntaxError from compile() in the ↵Miss Islington (bot)2024-05-291-1/+1
| | | | InteractiveColoredConsole (GH-119557) (#119709)
* [3.13] gh-119443: Turn off from __future__ import annotations in REPL ↵Miss Islington (bot)2024-05-291-1/+1
| | | | | | | | (GH-119493) (#119697) gh-119443: Turn off from __future__ import annotations in REPL (GH-119493) (cherry picked from commit a8e35e8ebad8c3bb44d14968aa05d1acbc028247) Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* [3.13] gh-111201: Speed up paste mode in the REPL (#119341) (GH-119432) ↵Miss Islington (bot)2024-05-235-15/+21
| | | | | | | | | | | | | | (#119439) (cherry picked from commit e6572e8f98d33994d2d0dd3afa92a2a72ee642a9) Also includes: * gh-111201: Use calc_complete_screen after bracketed paste in PyREPL (GH-119432) (cherry picked from commit 14b063cbf1bb11a489d04a31f277edba0fc8893c) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com> Co-authored-by: Łukasz Langa <lukasz@langa.pl> Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
* [3.13] gh-118911: Trailing whitespace in a block shouldn't prevent the user ↵Lysandros Nikolaou2024-05-232-3/+16
| | | | | | | | from terminating the code block (GH-119355) (#119404) (cherry picked from commit 5091c4400c9ea2a2d1e4d89a28c9d0de2651fa6d) Co-authored-by: Aya Elsayed <ayah.ehab11@gmail.com> Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* [3.13] gh-119434: Fix culmitive errors in wrapping as lines proceed ↵Miss Islington (bot)2024-05-231-3/+9
| | | | | | | | (GH-119435) (#119441) Fix culmitive errors in wrapping as lines proceed (cherry picked from commit e3bf5381fd056d0bbdd775463e3724aab2012e45) Co-authored-by: Dino Viehland <dinoviehland@gmail.com>
* [3.13] gh-111201: auto-indentation in _pyrepl (GH-119348) (#119427)Lysandros Nikolaou2024-05-221-3/+40
| | | | | | (cherry picked from commit cd516cd1f5e94dba887353f421513fd172efadf3) Co-authored-by: Arnon Yaari <wiggin15@yahoo.com> Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* [3.13] Enable some stricter mypy settings on `Lib/_pyrepl` (GH-119077) (#119428)Miss Islington (bot)2024-05-221-4/+1
| | | | | (cherry picked from commit 0883fd22e6d4a3e360b48f30f6afa34553b3786a) Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
* [3.13] gh-119357: Increase test coverage for keymap in _pyrepl (GH-119358) ↵Lysandros Nikolaou2024-05-222-35/+30
| | | | | | | | (#119414) (cherry picked from commit 73ab83b27f105a4509046ce26e35f20d66625195) Co-authored-by: Eugene Triguba <eugenetriguba@gmail.com> Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* [3.13] Improve `pyrepl` type-annotation coverage (GH-119081) (#119415)Miss Islington (bot)2024-05-226-14/+31
| | | | | (cherry picked from commit 033f5c87f1f876088701d1ae078dc39c41177d4a) Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
* [3.13] gh-118893: Evaluate all statements in the new REPL separately ↵Miss Islington (bot)2024-05-221-4/+29
| | | | | | | | (GH-119318) (#119408) (cherry picked from commit a3e4fec8734a304d654e4ae24a4aa2f41a7b0640) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com> Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* [3.13] gh-119205: Fix autocompletion bug in new repl (GH-119229) (#119407)Miss Islington (bot)2024-05-221-1/+3
| | | | | | (cherry picked from commit 506b1a3ff66a41c72d205c8e4cba574e439d8e76) Co-authored-by: Koudai Aono <koxudaxi@gmail.com> Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* [3.13] gh-111201: Add append to screen method to avoid recalculation ↵Miss Islington (bot)2024-05-224-14/+43
| | | | | | | | (GH-119274) (#119405) (cherry picked from commit c886bece3b3a49f8a0f188aecfc1d6ff89d281e6) Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com> Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* [3.13] gh-111201: Remove readline dependency from the PyREPL (GH-119262) ↵Lysandros Nikolaou2024-05-221-2/+2
| | | | | (#119403) (cherry picked from commit 561ff1fa710493dee8c6482f990bd17535b27040)
* [3.13] gh-118877: Fix AssertionError crash in pyrepl (GH-118936) (#119363)Miss Islington (bot)2024-05-221-3/+1
| | | | | (cherry picked from commit c0d81b256604a1079349d82d136db43eefcb3df1) Co-authored-by: Daniel Hollas <daniel.hollas@bristol.ac.uk>
* [3.13] gh-119035: Add Ctrl+← and Ctrl+→ word-skipping keybindings to new ↵Miss Islington (bot)2024-05-212-3/+8
| | | | | | | | repl (GH-119248) (#119323) add word-skipping ctrl keybindings to new repl (cherry picked from commit 0398d9339217aa0710c0de45a7e9b587136e7129) Co-authored-by: Alastair Stanley <alastairstanley@ntlworld.com>
* [3.13] gh-119185: Fix typo in `_pyrepl.pager`: `tempfilepager` should be ↵Miss Islington (bot)2024-05-201-1/+1
| | | | | | | | | | `tempfile_pager` (GH-118881) (#119211) Fix typo in `_pyrepl.pager`: `tempfilepager` should be `tempfile_pager` The name with no underscore doesn't exist. (cherry picked from commit 05e1dce76d7669e90ab73e7e682360d83b8a0d02) Co-authored-by: Thanos <111999343+Sachaa-Thanasius@users.noreply.github.com>
* gh-111201: Allow pasted code to contain multiple statements in the REPL ↵Pablo Galindo Salgado2024-05-074-4/+12
| | | | | (#118712) Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* gh-118682: Revert forcing str commands, allow class commands in pyrepl (#118709)Lysandros Nikolaou2024-05-071-3/+7
|
* gh-111201: Allow bracketed paste to work (GH-118700)Pablo Galindo Salgado2024-05-073-0/+21
|
* Remove several unused imports in `_pyrepl` (#118668)Nikita Sobolev2024-05-072-3/+0
|
* fix typo in `_pyrepl.pager`: `plainpager` -> `plain_pager` (#118675)denballakh2024-05-061-1/+1
|
* gh-118628: Don't display pyrepl warning on Windows (#118665)Łukasz Langa2024-05-061-3/+7
|
* gh-111201: A new Python REPL (GH-111567)Pablo Galindo Salgado2024-05-0521-0/+4230
Co-authored-by: Łukasz Langa <lukasz@langa.pl> Co-authored-by: Marta Gómez Macías <mgmacias@google.com> Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>