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
Add descriptive error message when environment variable not detected #23717
base: main
Are you sure you want to change the base?
Conversation
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA). CLA MissingOur records indicate the following people have not signed the CLA: For legal reasons we need all the people listed to sign the CLA before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. If you have recently signed the CLA, please wait at least one business day You can check yourself to see if the CLA has been received. Thanks again for the contribution, we look forward to reviewing it! |
This PR is stale because it has been open for 30 days with no activity. |
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.
Please create an issue on bpo to discuss this change.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
@iritkatriel Thank you for pointing me there- here is my post: https://bugs.python.org/issue44264 |
Lib/test/test_os.py
Outdated
@@ -1133,12 +1133,12 @@ def test_key_type(self): | |||
|
|||
with self.assertRaises(KeyError) as cm: | |||
os.environ[missing] | |||
self.assertIs(cm.exception.args[0], missing) | |||
self.assertIn(missing, cm.exception.args[0]) |
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.
Did you intend to make this change? If so, why?
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.
Now that the error message has more than just the key repr in it, I use assertIn
to ensure that the error message __contains__
the repr of missing
.
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.
(see updated code, which includes repr
)
I have made the requested changes; please review again |
Thanks for making the requested changes! @iritkatriel: please review the changes made to this pull request. |
Do I need to add the skip labels myself or does a reviewer do it? |
Using
os.environ[KEY]
with a non-existent environment variable key only gave a simple KeyError, so now, the error message should make more sense when encountered. Obviously, fix my style if it's not up to standard.Linked bugtracker post: https://bugs.python.org/issue44264