Skip to content

Commit b81c0e2

Browse files
authored
Merge pull request #8344 from jepler/repl-py
add support for "repl.py"
2 parents 3605d89 + d7cf11d commit b81c0e2

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

README.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ Behavior
133133
``code.py`` **in the REPL anymore, as the REPL is a fresh vm.** CircuitPython's goal for this
134134
change includes reducing confusion about pins and memory being used.
135135
- After the main code is finished the REPL can be entered by pressing any key.
136+
- If the file ``repl.py`` exists, it is executed before the REPL Prompt is shown
137+
- In safe mode this functionality is disabled, to ensure the REPL Prompt can always be reached
136138
- Autoreload state will be maintained across reload.
137139

138140
- Adds a safe mode that does not run user code after a hard crash or brown out. This makes it
@@ -155,7 +157,7 @@ Behavior
155157
- Re-runs ``code.py`` or other main file after file system writes by a workflow. (Disable with
156158
``supervisor.disable_autoreload()``)
157159
- Autoreload is disabled while the REPL is active.
158-
- ``code.py`` may also be named``code.txt``, ``main.py``, or ``main.txt``.
160+
- ``code.py`` may also be named ``code.txt``, ``main.py``, or ``main.txt``.
159161
- ``boot.py`` may also be named ``boot.txt``.
160162
- ``safemode.py`` may also be named ``safemode.txt``.
161163

main.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,11 @@ STATIC int run_repl(safe_mode_t safe_mode) {
934934

935935
autoreload_suspend(AUTORELOAD_SUSPEND_REPL);
936936

937+
if (get_safe_mode() == SAFE_MODE_NONE) {
938+
const char *const filenames[] = { "repl.py" };
939+
(void)maybe_run_list(filenames, MP_ARRAY_SIZE(filenames));
940+
}
941+
937942
// Set the status LED to the REPL color before running the REPL. For
938943
// NeoPixels and DotStars this will be sticky but for PWM or single LED it
939944
// won't. This simplifies pin sharing because they won't be in use when

0 commit comments

Comments
 (0)