Currently, launching Python without the _pyrepl module present causes it to abort. It would be better if it simply went into regular repl mode, rather than requiring the user to set an env var, as this would allow distributors to simply omit the module rather than having to patch and rebuild CPython.
fprintf(stderr, "Could not import _pyrepl.main\n");
res=pymain_exit_err_print();
goto done;
}
I would prefer messages about ModuleNotFoundError here to only be shown in verbose mode, though other errors could still cause a full failure (if that's what the maintainers think is best... I disagree, but it's not important to me like ModuleNotFoundError would be).
Given how pydoc was refactored, and that I don't want to un-refactor it, it appears that omitting _pyrepl will also break pydoc. I expect that to not be an issue for anyone who's interested in restricting REPL usage (e.g. in production code), so will just leave it documented. Turns out to not be an issue, though pydoc does regress to its most basic form without _pyrepl (which I still think is okay).
Activity
zooba commented on Feb 23, 2026
Given how pydoc was refactored, and that I don't want to un-refactor it, it appears that omitting _pyrepl will also break pydoc. I expect that to not be an issue for anyone who's interested in restricting REPL usage (e.g. in production code), so will just leave it documented. Turns out to not be an issue, though pydoc does regress to its most basic form without _pyrepl (which I still think is okay).
pythongh-145035: Allows removing the _pyrepl module to completely dis…
pythongh-145035: Allows removing the _pyrepl module to completely dis…
gh-145035: Allows removing the _pyrepl module to completely disable t…
StanFromIreland commented on Mar 15, 2026
Triage: Can this be closed now?
pythongh-145035: Allows removing the _pyrepl module to completely dis…