Skip to content

shared/runtime/pyexec: Don't execute empty line in event driven REPL. - #19587

Open
dpgeorge wants to merge 1 commit into
micropython:masterfrom
dpgeorge:shared-runtime-fix-event-repl-empty-line
Open

shared/runtime/pyexec: Don't execute empty line in event driven REPL.#19587
dpgeorge wants to merge 1 commit into
micropython:masterfrom
dpgeorge:shared-runtime-fix-event-repl-empty-line

Conversation

@dpgeorge

@dpgeorge dpgeorge commented Aug 7, 2026

Copy link
Copy Markdown
Member

Summary

Commit 617c7db exposed a bug in the event driven REPL code: an empty input line (user pressing enter without entering anything else) would pass a zero-length string to parse_compile_execute() and this is not valid input to mp_lexer_new_from_str_len(), which requires at least one character in the input string.

Fix that by restarting the input REPL state machine when nothing is entered. This follows how the non-event-driver REPL code works.

Fixes issue #19583.

Testing

Tested with webassembly port:

$ make VARIANT=pyscript repl

then pressing enter many times in a row. It now correctly just reissues >>>, rather than raising SyntaxError.

Trade-offs and Alternatives

Could fix it in mp_lexer_new() by making that handle a zero-length input stream. But that adds code to ports which don't need the fix, and fixing it in pyexec.c follows exactly how the non-event-driver REPL works.

Generative AI

I did not use generative AI tools when creating this PR.

Commit 617c7db exposed a bug in the event
driven REPL code: an empty input line (user pressing enter without entering
anything else) would pass a zero-length string to `parse_compile_execute()`
and this is not valid input to `mp_lexer_new_from_str_len()`, which
requires at least one character in the input string.

Fix that by restarting the input REPL state machine when nothing is
entered.  This follows how the non-event-driver REPL code works.

Fixes issue micropython#19583.

Signed-off-by: Damien George <damien@micropython.org>
@dpgeorge dpgeorge added the shared Relates to shared/ directory in source label Aug 7, 2026
@dpgeorge dpgeorge added this to the release-1.29.0 milestone Aug 7, 2026
@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.55%. Comparing base (d9f669a) to head (effa56f).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #19587   +/-   ##
=======================================
  Coverage   98.55%   98.55%           
=======================================
  Files         182      182           
  Lines       23303    23303           
  Branches        5        5           
=======================================
  Hits        22967    22967           
  Misses        335      335           
  Partials        1        1           
Flag Coverage Δ
unix-coverage-32bit 98.56% <ø> (ø)
unix-coverage-64bit 98.52% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

Code size report:

Reference:  py/modmicropython: Support scheduling a KeyboardInterrupt from Python. [d9f669a]
Comparison: shared/runtime/pyexec: Don't execute empty line in event driven REPL. [merge of effa56f]
  mpy-cross:    +0 +0.000% 
   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:    +0 +0.000% PYBV10
      esp32:    +0 +0.000% ESP32_GENERIC
     mimxrt:    +0 +0.000% TEENSY40
        rp2:    +0 +0.000% RPI_PICO_W
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
  qemu rv32:    +0 +0.000% VIRT_RV32

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

Labels

shared Relates to shared/ directory in source

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant