Repository navigation
Add a simple REPL. - #460
Conversation
|
Nice idea. I suppose this gives us an interactive way to excite the interpreter without adding an example program. As I understand it, this keeps a CPython running that is executing a script where it receives REPL input and returns marshalled code objects. It seems like this script is supplied on the command line with I haven't been able to run it on Windows. The real cause is probably a limitation on the length of a command line, as the message I get is: This is a truncated bit of text from `repl_compiler.py". Or it may be something to do with quote characters, given one is missing. |
@jeff5 , have you tried installing WSL 3.0 with creates a lightweight Ubuntu Linux environment in Win11? https://www.zdnet.com/article/windows-subsystem-for-linux-3-for-developers-sticking-with-microsoft/ I'm able to build and run Jython in the WSL 3.0 environment.
|
Jython 2 runs fine on Windows. |
Use one name, jython.cpython, for the Gradle property and the system property. Gradle and ReplCompiler both resolve it as jython.cpython, then JYTHON_CPYTHON, then "python". Run repl_compiler.py from a temp file instead of with -c. On Windows, Java doesn't escape the double quotes in a -c argument, which corrupted the script. Run unit tests on Windows as well as Ubuntu, passing CPython through JYTHON_CPYTHON to avoid quoting problems in PowerShell.
Normalise line endings in ReplTest output println writes "\r\n" on Windows, so the expected REPL output did not match. Compare captured output with line endings as "\n".
Moving this to |
As suggested in review. Interpreter, its constructor, and eval() become public so that the REPL can run code from outside org.python.core.
noneOrStrError returns the TypeError and print() throws it, making the termination clear at the call site. Comment that displayHook is a stop-gap until there is a sys module providing sys.displayhook and sys.stdout.
|
|
That's such fun! And useful for debugging with the right wrapper. I'm looking forward to merging this from It's very tempting to set about adding opcodes, but there are bigger fish to fry. ctrl-D doesn't let me out on Windows. Evidently it reaches the application, and all it has to say is "that's interesting" :). But Gradle or PoSh is listening for ctrl-C: I'd merge this without, but if you wanted to honour the promise "Ctrl-D to exit", that would be nice. I'll leave a few days in case you want to add it. |

Add a simple REPL that uses a cpython subprocess to do the compiling modeled on cpython's Lib/code.py especially InteractiveConsole
To try it out run:
./gradlew -q --console=plain core.repl
If you want history:
rlwrap ./gradlew -q --console=plain core:repl
On my mac I need to specify python3.11 (then for convenience I put it
cpython=python3.11into ~/.gradle/gradle.properties):./gradlew -q --console=plain -Pcpython=python3.11 core:repl