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

Closed
7 tasks done
pablogsal opened this issue Oct 23, 2023 · 49 comments
Closed
7 tasks done

A new Python REPL #111201

pablogsal opened this issue Oct 23, 2023 · 49 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
Member

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)

vstinner added a commit that referenced this issue May 31, 2024
Don't attempt to load pyrepl Windows console if platforms others than
Windows. For example, the import can fail if ctypes is missing.
ambv added a commit that referenced this issue May 31, 2024
(cherry picked from commit 0d07182)

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>
vstinner added a commit to vstinner/cpython that referenced this issue Jun 1, 2024
Don't attempt to load pyrepl Windows console if platforms others than
Windows. For example, the import can fail if ctypes is missing.

(cherry picked from commit 91601a5)
vstinner added a commit that referenced this issue Jun 1, 2024
gh-111201: Skip pyrepl Windows tests earlier (#119848)

Don't attempt to load pyrepl Windows console if platforms others than
Windows. For example, the import can fail if ctypes is missing.

(cherry picked from commit 91601a5)
noahbkim pushed a commit to hudson-trading/cpython that referenced this issue Jul 11, 2024
Co-authored-by: Anthony Shaw <anthony.p.shaw@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
noahbkim pushed a commit to hudson-trading/cpython that referenced this issue Jul 11, 2024
- auto-indent when editing multi-line block
- ignore comments
noahbkim pushed a commit to hudson-trading/cpython that referenced this issue Jul 11, 2024
noahbkim pushed a commit to hudson-trading/cpython that referenced this issue Jul 11, 2024
Don't attempt to load pyrepl Windows console if platforms others than
Windows. For example, the import can fail if ctypes is missing.
estyxx pushed a commit to estyxx/cpython that referenced this issue Jul 17, 2024
estyxx pushed a commit to estyxx/cpython that referenced this issue Jul 17, 2024
estyxx pushed a commit to estyxx/cpython that referenced this issue Jul 17, 2024
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
estyxx pushed a commit to estyxx/cpython that referenced this issue Jul 17, 2024
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
estyxx pushed a commit to estyxx/cpython that referenced this issue Jul 17, 2024
estyxx pushed a commit to estyxx/cpython that referenced this issue Jul 17, 2024
Co-authored-by: Anthony Shaw <anthony.p.shaw@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
estyxx pushed a commit to estyxx/cpython that referenced this issue Jul 17, 2024
- auto-indent when editing multi-line block
- ignore comments
estyxx pushed a commit to estyxx/cpython that referenced this issue Jul 17, 2024
estyxx pushed a commit to estyxx/cpython that referenced this issue Jul 17, 2024
Don't attempt to load pyrepl Windows console if platforms others than
Windows. For example, the import can fail if ctypes is missing.
wiggin15 added a commit to wiggin15/cpython that referenced this issue Aug 19, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Sep 6, 2024
…pythonGH-123196)

(cherry picked from commit d683f49)

Co-authored-by: Arnon Yaari <wiggin15@yahoo.com>
ambv pushed a commit that referenced this issue Sep 6, 2024
GH-123196) (GH-123764)

(cherry picked from commit d683f49)

Co-authored-by: Arnon Yaari <wiggin15@yahoo.com>
@lysnikolaou
Copy link
Contributor

I think we can close this and handle the rest of the bugs in individual issues. Feel free to re-open if you feel otherwise.

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