gh-136251: Improvements to WASM demo REPL by adqm · Pull Request #136252 · python/cpython · GitHub | Latest TMZ Celebrity News & Gossip | Watch TMZ Live
Skip to content

gh-136251: Improvements to WASM demo REPL #136252

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

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open

Conversation

adqm
Copy link

@adqm adqm commented Jul 3, 2025

I'm including a couple of fixes for the WASM demo, which for me made the demo "just work" out of the box for me with a build from following the instructions on this page:

  • Exported HEAPU32 at build time since python.worker.mjs expects it to be there (for determining the version number)
  • Updated the HTML to properly load xterm.js

I also made a few changes to try to improve the usability of the web REPL, also included here:

  • Reset things when starting a new process (without this change, running the same program multiple times would not work, requiring a refresh)
  • Added support for arrow key navigation (and home/end) in the REPL (including history scrollback)
  • Added support for TAB and CTRL+C, trying to mimic the behavior of the regular of those inputs from the Python REPL
  • Replaced the textarea with Ace code editor.
  • Moved the demo to index.html instead of python.html so that the URL shown in the terminal when running server.py takes you to the demo (without needing to append /python.html)

I also put up a demo here that shows the result of a fresh Emscripten build with these changes.

There's definitely still room for improvement here (for example, #124621 suggests updating the demo to use PyREPL), but I'm sharing these changes in case they're useful in the meantime.

Related Issue: #136251

@python-cla-bot
Copy link

python-cla-bot bot commented Jul 3, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app
Copy link

bedevere-app bot commented Jul 3, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@adqm adqm requested a review from brettcannon as a code owner July 3, 2025 17:52
@bedevere-app
Copy link

bedevere-app bot commented Jul 3, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@bedevere-app
Copy link

bedevere-app bot commented Jul 3, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@bedevere-app
Copy link

bedevere-app bot commented Jul 3, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a full review, just saw some style problems :)

updateHistory(){
if (this.historyIndex !== -1){
this.historyBuffer[this.historyIndex] = this.input;
}else{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style nit:

Suggested change
}else{
} else {

}

updateHistory(){
if (this.historyIndex !== -1){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style nit:

Suggested change
if (this.historyIndex !== -1){
if (this.historyIndex !== -1) {

<div class="button-container">
<button id="run" disabled>Run</button>
<button id="run" disabled>Run Code</button>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<button id="run" disabled>Run Code</button>
<button id="run" disabled>Run code</button>

}
};

clearLine(){
this.xterm.write('\x1b[K')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
this.xterm.write('\x1b[K')
this.xterm.write('\x1b[K');

@brettcannon brettcannon removed their request for review July 3, 2025 21:01
@bedevere-app
Copy link

bedevere-app bot commented Jul 3, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@adqm
Copy link
Author

adqm commented Jul 3, 2025

thanks, @sobolevn! i just ran prettier on that file; it looks like it caught those style issues and quite a few more.

@bedevere-app
Copy link

bedevere-app bot commented Jul 3, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants

TMZ Celebrity News – Breaking Stories, Videos & Gossip

Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

🎥 Watch TMZ Live

TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.