From 6e83963267345494587f31d1a44c2a07620f2863 Mon Sep 17 00:00:00 2001 From: Rafid Aslam Date: Sun, 27 Oct 2024 14:42:19 +0700 Subject: [PATCH] gh-125873: Improve error message when `PYTHONHOME` is invalid --- .../2024-10-27-22-23-57.gh-issue-125873.BG97KU.rst | 1 + Python/codecs.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Core_and_Builtins/2024-10-27-22-23-57.gh-issue-125873.BG97KU.rst diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2024-10-27-22-23-57.gh-issue-125873.BG97KU.rst b/Misc/NEWS.d/next/Core_and_Builtins/2024-10-27-22-23-57.gh-issue-125873.BG97KU.rst new file mode 100644 index 000000000000000..4a0b63d4300105c --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2024-10-27-22-23-57.gh-issue-125873.BG97KU.rst @@ -0,0 +1 @@ +Improved error message when ``PYTHONHOME`` is invalid diff --git a/Python/codecs.c b/Python/codecs.c index 2cb3875db350588..91799cf22434fa4 100644 --- a/Python/codecs.c +++ b/Python/codecs.c @@ -1526,7 +1526,7 @@ _PyCodec_InitRegistry(PyInterpreterState *interp) // search functions, so this is done after everything else is initialized. PyObject *mod = PyImport_ImportModule("encodings"); if (mod == NULL) { - return PyStatus_Error("Failed to import encodings module"); + return PyStatus_Error("Failed to import encodings module. Are you sure PYTHONHOME is correct?"); } Py_DECREF(mod);