-
-
Notifications
You must be signed in to change notification settings - Fork 30.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-125873: Improve error message when PYTHONHOME is invalid #126027
base: main
Are you sure you want to change the base?
gh-125873: Improve error message when PYTHONHOME is invalid #126027
Conversation
refeed
commented
Oct 27, 2024
•
edited by bedevere-app
bot
Loading
edited by bedevere-app
bot
- Issue: Show a better error message when PYTHONHOME is wrong #125873
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
63de824
to
c14d804
Compare
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
This is user-facing, so it needs a NEWS entry. Something like "Improved error message when |
Hi @ZeroIntensity , thanks for that! Just added it through the heroku blurb, please let me know if there's something I need to do, thanks |
Misc/NEWS.d/next/Core_and_Builtins/2024-10-27-22-23-57.gh-issue-125873.BG97KU.rst
Outdated
Show resolved
Hide resolved
6c9bdc4
to
6e83963
Compare
6e83963
to
c4156f6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! It's good to see new contributors :)
I doubt that we need a special treatment just for one environment variable. Same error happens if you wrongly override other |
@refeed, please avoid rebase/force-pushes/etc next time. Just add new commits while your pr being reviewed. |
Python/codecs.c
Outdated
@@ -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?"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we tell the user what the (wrong) value of PYTHONHOME
is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could, but that significantly complicates things, because the error message has to get put on the heap (PyStatus
can't do that, AFAIK). There's also a chance it's unset in the case of embedding.
Eh, I disagree. I've encountered this error myself, it's common when embedding the interpreter because if |
Alright, for the env link can I use this: https://docs.python.org/3/using/cmdline.html#environment-variables ? I'm thinking that the final error message will be:
I think we still have to mention the What do you think? |
If we're going to go the route of casing this for all invalid variables (I'm not fully convinced, but let's go with it for now), then I don't think actually putting a link to the docs is the right way to do it. We should sort of hint where to look in the docs, something like this should work:
|
There's some contention about what should happen here. I'm dismissing my review until that gets solved.
Misc/NEWS.d/next/Core_and_Builtins/2024-10-27-22-23-57.gh-issue-125873.BG97KU.rst
Outdated
Show resolved
Hide resolved
@skirpichev This is a more extensive message now, do you like this better? |
Yes, looks better. Perhaps we could add some reference to |
Alright, how about this?
|
I believe mentioning PYTHONHOME explicitly is important, see the examples in #125873. As a user, the error message links me to |
Alright, how about this?
|