Skip to content

Commit 3d76ed8

Browse files
committed
Fix pymain_run_stdin() in Modules/main.c to call pymain_start_pyrepl() instead of pymain_run_module(L"_pyrepl", 0)
This change is an equivalent to the one done in https://github.com/python/cpython/pull/120904/files#diff-79e40dbd94b164b5f42a960224cc7496e33c189b4c66a6810904eda7d703b6f2R600 Two callers of `pymain_start_pyrepl` differs in whether the PYTHONSTARTUP script is already executed or not, so pythonstartup argument is added to `pymain_start_pyrepl` to control whether it should be executed in it or not.
1 parent b681275 commit 3d76ed8

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Modules/main.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ pymain_run_command(wchar_t *command)
269269

270270

271271
static int
272-
pymain_start_pyrepl(void)
272+
pymain_start_pyrepl(int pythonstartup)
273273
{
274274
int res = 0;
275275
PyObject *console = NULL;
@@ -306,7 +306,7 @@ pymain_start_pyrepl(void)
306306
goto done;
307307
}
308308
if (!PyDict_SetItemString(kwargs, "mainmodule", main_module)
309-
&& !PyDict_SetItemString(kwargs, "pythonstartup", _PyLong_GetOne())) {
309+
&& !PyDict_SetItemString(kwargs, "pythonstartup", pythonstartup ? Py_True : Py_False)) {
310310
console_result = PyObject_Call(console, empty_tuple, kwargs);
311311
if (console_result == NULL) {
312312
res = pymain_exit_err_print();
@@ -570,7 +570,7 @@ pymain_run_stdin(PyConfig *config)
570570
int run = PyRun_AnyFileExFlags(stdin, "<stdin>", 0, &cf);
571571
return (run != 0);
572572
}
573-
return pymain_run_module(L"_pyrepl", 0);
573+
return pymain_start_pyrepl(0);
574574
}
575575

576576

@@ -603,7 +603,7 @@ pymain_repl(PyConfig *config, int *exitcode)
603603
*exitcode = (run != 0);
604604
return;
605605
}
606-
int run = pymain_start_pyrepl();
606+
int run = pymain_start_pyrepl(1);
607607
*exitcode = (run != 0);
608608
return;
609609
}

0 commit comments

Comments
 (0)