-
-
Notifications
You must be signed in to change notification settings - Fork 497
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
Use explicit environment on subprocess #1546
Conversation
Tested locally on my system, under both conda and pyenv environments, I'm not sure what purpose this assertion serves, since you've increased it recently from 21... Note that I do not know what effects there will be on Windows systems. In the subproccess.Popen documentation, I found:
|
Thanks for this patch!
That's fine I guess, the Windows CI passes. If it doesn't work for people, I guess I will hear from them :).
This is test is there to ensure that the actual completions for os are not too different from typeshed's definitions. It would probably need a bit of love to make it pass on virtualenvs as well. (Just raising the numbers is not really what I want). |
env = {} | ||
if os.name == 'nt': | ||
# Windows requires SYSTEMROOT | ||
env.update(SYSTEMROOT=os.environ.get('SYSTEMROOT')) |
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.
Minor issue: While SYSTEMROOT is probably defined most of the time, if it is not we should just not set it. The problem is essentially that it could be empty. If it is we cannot set it:
>>> os.environ['asdf'] = None
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.5/os.py", line 730, in __setitem__
value = self.encodevalue(value)
File "/usr/lib/python3.5/os.py", line 798, in encode
raise TypeError("str expected, not %s" % type(value).__name__)
TypeError: str expected, not NoneType
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.
Another issue: Windows environment variables are case insensitive, so it also be SYSTEMROOT
, SystemRoot
, or maybe systemroot
. I'll put in some robustness and if none are present, I'll refrain from setting.
…environment variables are not inherited. This ensures more reliable results, see issue davidhalter#1540. * Attempt to send SYSTEMROOT variable to Windows subprocess
fa3d36e
to
b385d4b
Compare
Thanks again for you work here and the good reasoning :). |
Resolves #1540.
Use an explicit environment for subprocess to ensure that existing environment variables are not inherited. This ensures more reliable results.