-
-
Notifications
You must be signed in to change notification settings - Fork 780
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
Improving console.html #875
Conversation
""" | ||
def __init__(self, flush_callback): | ||
buffer = io.BufferedWriter(CallbackBuffer(flush_callback)) | ||
super().__init__(buffer, line_buffering=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please move these 3 classes to src/pyodide.py
, keep them private (e.g. _ConsoleStdStream
, _ConsoleCallbackBuffer
, _Console
) and add some unit tests for them in src/tests/test_pyodide.py
. Eventually we might make an actual pyodide Python package with multiple modules, but for now I thing putting everything in a single file is fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that this should be tested but do you think src/pyodide.py
is the better place to put REPL stuff?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise we would need to address #896 first and then put it under pyodide/console.py
. Maybe that would be better indeed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Answered to #896 where your proposal makes sense. However, should this be blocking for this PR?
Hello @casatir, thank you for your contribution. I'm also of the same opinion, the REPL is a very important place to start with. I've just compiled and tested your branch, it runs well, but I found about another problem: s = input() shows a JavaScript prompt() in 0.15.0 (anyway, I doesn't return anything), but now yields in an error
Is there a way to resolve this? Please do also update the CHANGELOG.md. |
I will update the changelog and put console stuff in Are you sure about the |
you're right... I've just built it again and it works. Then forget about it. |
Here is an attempt to fix #897 . Seems OK but namespace is polluted by imports and variables from the REPL code. Not tab completion on filepath (not supported by |
Great thanks! We can look into improving that situation in a separate PR.
I'll try to make a PR to create that package soon, but it's not a blocker. However we need tests for those classes to merge this PR, which for now probably means putting them into |
I think I have a working console with:
It is fully implemented in Python and demonstrates the Pyodide ability to interpret itself. That's a lot of changes that I'll split into several PR. See you soon! |
console.html
is a great tool. It's a showcase for Pyodide and the devel version allows developers to track issues and make quick tests.Unfortunately, IMHO, it lacks some important features like:
repr
(type"1"
and it shows1
, typeglobals()
and it shows[object Object]
)While 1. and 2. are addressed in this PR, 3. seems tricky, at least with the current setup (JQuery's terminal +
copy.py
interactive console +runPythonAscyn
) but not impossible (see Basthon).Getting correct representations for basic types (like strings) are addressed in this PR. Difficulty to get correct
repr
for complex objects comes from the fact that, when you get a Python object on the JS side (e.g. runPython[Async]'s result), it seems impossible to get it back into Python. As an illustration, compare the result of the two following code snippets:Long story short,
Any idea to fully address 3.with the current setup?
Should I edit changelog ?
Closes #897