import-expression-parser icon indicating copy to clipboard operation
import-expression-parser copied to clipboard

Update REPL based on `asyncio.__main__` in CPython 3.14

Open Sachaa-Thanasius opened this issue 1 year ago • 1 comments

Technically, more could've been done, but I tried to make the diff minimal for this PR. Some changes include:

  • Adding a return code and keeping it updated so that the REPL can return non-0 values on failure.
  • Running the python startup file before the REPL starts (for better emulation of the actual REPL).
  • Other tidbits (can be enumerated if need be).

Some notes:

  • At the moment, this does not try to remove support for <3.8.
  • This explicitly avoids using _pyrepl because it isn't stable yet and doesn't have a public API.

Sachaa-Thanasius avatar Oct 23 '24 06:10 Sachaa-Thanasius

I mentioned this in discord, but I'm also putting it here for continuity: turns out codeop.PyCF_ALLOW_INCOMPLETE_INPUT doesn't exist prior to 3.10. That's problematic.

Maybe the differences in codeop before and after that constant (that parser option, really) was added are minimal enough that we can implement branching logic based on its existence. If so, we could use whatever logic codeop had before, bugs and all, to support at least 3.9. I'll try to see if that's the case.

Relevant Links

  • Issue that caused it to get added: https://github.com/python/cpython/issues/90679
  • Commit that added it: https://github.com/python/cpython/commit/69e10976b2e7682c6d57f4272932ebc19f8e8859

Sachaa-Thanasius avatar Oct 23 '24 10:10 Sachaa-Thanasius