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 00000000000000..fc4818781ee132 --- /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 an environment variable is misconfigured. diff --git a/Python/codecs.c b/Python/codecs.c index 2cb3875db35058..1f30c5e8e21707 100644 --- a/Python/codecs.c +++ b/Python/codecs.c @@ -1526,7 +1526,9 @@ _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. " + "Your environment probably has misconfigured variables! " + "Please check PYTHONHOME otherwise refer to `--help-env`"); } Py_DECREF(mod);