-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
Not guarding env value in subprocess.py cause python crash when certain env variable is set to None #99238
Comments
Environment dictionaries are string to string maps. - https://docs.python.org/3/library/os.html#os.environ While the subprocess module docs do not explicitly say this, the intent was always that this dict matched the type you'd find in |
Do you think there's a stricter type checking approach we could take rather than the PR I proposed? I ran into a library that does this and unfortunately took quite a while to debug. I'd love your feedback on this matter, thanks. |
We shouldn't be adding assertions into the standard library because of uncommon bugs in calling code. However if you use a static analysis tool like pytype or mypy it should catch this one as the subprocess API definition in https://github.com/python/typeshed/blob/main/stdlib/subprocess.pyi#L73 that python type checkers is correct for env. None is not allowed. |
(cherry picked from commit 2eee9d9) Co-authored-by: Gregory P. Smith <[email protected]>
(cherry picked from commit 2eee9d9) Co-authored-by: Gregory P. Smith <[email protected]>
(cherry picked from commit 2eee9d9) Co-authored-by: Gregory P. Smith <[email protected]>
(cherry picked from commit 2eee9d9) Co-authored-by: Gregory P. Smith <[email protected]>
Thanks Gregory, this looks really good |
Bug report
A minimal bug can be found using the following file
Your environment
M1 MacOS Monterey, python 3.10
x86_64 Ubuntu 20.04 LTS, python 3.11 (installed via pyenv)
The text was updated successfully, but these errors were encountered: