Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A new Python REPL #111201

Open
7 tasks done
pablogsal opened this issue Oct 23, 2023 · 48 comments
Open
7 tasks done

A new Python REPL #111201

pablogsal opened this issue Oct 23, 2023 · 48 comments
Assignees
Labels
topic-repl Related to the interactive shell

Comments

@pablogsal
Copy link
Member

pablogsal commented Oct 23, 2023

This issue will track all the different steps to bootstrap a new Python REPL with many new features. The target of this issue is that we can reach a point where new contributions can be made easily to the REPL once is written in pure Python. This issue only coveres the initial ground work to reach this status.

Tasks to be done:

  • Redirect the parser and the main module to a new Python module.
  • Fallback to the previous tokenizer-based REPL if the terminal is not a tty (and for backwards compat reasons)
  • Bootstrap a new REPL module (based on a trimmed version pypy's pyrepl module).
  • Ensure that the basic features work:
    • History
    • Completions
    • Ctrl-r and Ctrl-s

Linked PRs

@pablogsal
Copy link
Member Author

If you want to help with this endeavour, please mention it here so we can coordinate everyone!

@pablogsal
Copy link
Member Author

I have a initial version that we can start building upon, I will create a PR shortly.

@tomasr8
Copy link
Contributor

tomasr8 commented Oct 23, 2023

I learned about this from the "core.py" podcast and it sounds like a great idea! I'd be happy help with this effort :)

pablogsal added a commit to pablogsal/cpython that referenced this issue Oct 31, 2023
@vstinner
Copy link
Member

vstinner commented Nov 1, 2023

Fallback to the previous tokenizer-based REPL if the terminal is not a tty (and for backwards compat reasons)

Do you mean not using _pyrepl? Can _pyrepl be used without readline nor tty?

@pablogsal
Copy link
Member Author

Can _pyrepl be used without readline nor tty?

It needs at least a tty yes. Readline can be lifted but I am not sure yet

@novaTopFlex
Copy link

I would like to see a new REPL (read, evaluate, print, loop) for the Python interpreter if the interpreter goes by a different name. Two other major Python interpreters also exist, and they already use other names ("bpython" and "ipython"). I would recommend forking the current REPL and renaming the interpreter with the new REPL to "zpython" instead. Also, I would like to see a built-in "clear()" function in the REPL as I already encounter with the "exit()" function and other REPL-specific functions.

ambv added a commit that referenced this issue May 5, 2024
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>
pablogsal added a commit to pablogsal/cpython that referenced this issue May 5, 2024
pablogsal added a commit to pablogsal/cpython that referenced this issue May 5, 2024
@theLastOfCats
Copy link

Big feature without PEP?

@encukou
Copy link
Member

encukou commented May 6, 2024

Most buildbots are broken with:

Traceback (most recent call last):
  File ".../Lib/unittest/mock.py", line 1420, in patched
    return func(*newargs, **newkeywargs)
  File ".../Lib/test/test_pyrepl.py", line 643, in test_push_without_key_in_keymap
    eq = EventQueue(sys.stdout.fileno(), "utf-8")
                    ~~~~~~~~~~~~~~~~~^^
io.UnsupportedOperation: fileno

e.g.: https://buildbot.python.org/all/#/builders/725/builds/7939/steps/5/logs/stdio

@pablogsal
Copy link
Member Author

Checking, will make a PR this morning

@lysnikolaou
Copy link
Contributor

I already have something, will push in a bit.

@kulikjak
Copy link
Contributor

kulikjak commented May 6, 2024

Hi, I am seeing the following error:

======================================================================
FAIL: test_completion_with_many_options (test.test_pyrepl.TestPyReplCompleter.test_completion_with_many_options)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/..../cpython-main/Lib/test/test_pyrepl.py", line 586, in test_completion_with_many_options
    self.assertEqual(output, "os.O_ASYNC")
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 'os.O_AS' != 'os.O_ASYNC'
- os.O_AS
+ os.O_ASYNC
?        +++

The reason is most likely that os.O_ASYNC is not necessarily available on all platforms (I am seeing this on Solaris where it's missing). I tried replacing it with O_AP and O_APPEND and then it works as expected.

@hauntsaninja
Copy link
Contributor

hauntsaninja commented May 6, 2024

(hmm there is only one constant starting with os.O_AS, so not sure where the "with_many_options" comes in. should it just be testing os.O_? if anything test_simple_completion tests multiple options because of getenv and getenvb)

lysnikolaou added a commit to lysnikolaou/cpython that referenced this issue May 20, 2024
pablogsal added a commit to pablogsal/cpython that referenced this issue May 21, 2024
pablogsal added a commit to pablogsal/cpython that referenced this issue May 21, 2024
pablogsal added a commit to pablogsal/cpython that referenced this issue May 21, 2024
ambv added a commit that referenced this issue May 22, 2024
ambv added a commit that referenced this issue May 22, 2024
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
ambv added a commit that referenced this issue May 22, 2024
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
lysnikolaou added a commit to lysnikolaou/cpython that referenced this issue May 22, 2024
…ythonGH-119262)

(cherry picked from commit 561ff1f)

Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue May 22, 2024
…ythonGH-119274)

(cherry picked from commit c886bec)

Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
lysnikolaou added a commit that referenced this issue May 22, 2024
lysnikolaou added a commit that referenced this issue May 22, 2024
…H-119274) (#119405)

(cherry picked from commit c886bec)

Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
lysnikolaou pushed a commit to lysnikolaou/cpython that referenced this issue May 22, 2024
(cherry picked from commit cd516cd)

Co-authored-by: Arnon Yaari <wiggin15@yahoo.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
lysnikolaou pushed a commit to lysnikolaou/cpython that referenced this issue May 22, 2024
(cherry picked from commit cd516cd)

Co-authored-by: Arnon Yaari <wiggin15@yahoo.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
lysnikolaou added a commit to lysnikolaou/cpython that referenced this issue May 22, 2024
ambv added a commit that referenced this issue May 22, 2024
(cherry picked from commit cd516cd)

Co-authored-by: Arnon Yaari <wiggin15@yahoo.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue May 22, 2024
…REPL (pythonGH-119432)

(cherry picked from commit 14b063c)

Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
lysnikolaou pushed a commit to miss-islington/cpython that referenced this issue May 23, 2024
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
lysnikolaou added a commit to miss-islington/cpython that referenced this issue May 23, 2024
…REPL (pythonGH-119432)

(cherry picked from commit 14b063c)

Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
lysnikolaou added a commit that referenced this issue May 23, 2024
… (#119439)

(cherry picked from commit e6572e8)

Also includes:

* gh-111201: Use calc_complete_screen after bracketed paste in PyREPL (GH-119432)
(cherry picked from commit 14b063c)

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-repl Related to the interactive shell
Projects
None yet
Development

No branches or pull requests