| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Environment variables set by os.environ and os.putenv() are now cleared at exit. Python manages their memory which is released at exit.
|
cc @eduardo-elizondo @ericsnowcurrently @serhiy-storchaka @encukou (author and reviewers of PR #10854 and PR #15892). |
Sorry, something went wrong.
| #ifdef HAVE_UNSETENV | ||
| posix_unset_envvars(_posixstate(module)->posix_putenv_garbage); | ||
| #endif | ||
| Py_CLEAR(_posixstate(module)->posix_putenv_garbage); |
There was a problem hiding this comment.
Given that you are already doing these fixes around this, posix_putenv_garbage should also be guarded by HAVE_PUTENV (check its initialization in the init function).
Sorry, something went wrong.
|
Good catch, looks good to me 👍 |
Sorry, something went wrong.
|
Should the docs for os.environ and os.putenv be updated to note this explicit deletion? Is it possible that, on some platforms, existing programs might be using the current undefined behavior without crashing and thus might break with this change so it should be documented? |
Sorry, something went wrong.
Yes, it is possible. Python 3.8 was safe: the memory was never released, so environment variables remained available and didn't crash. I will first implement https://bugs.python.org/issue39406 before updating this PR to document the incompatible change. |
Sorry, something went wrong.
This issue is now implemented: os.putenv() is now implemented with setenv() if setenv() is available. So I proposed PR #18135 to fix bpo-39395 differently: on non-Windows platforms, Python now requires setenv() to build. This PR has no backward compatibility issue: it doesn't unset environment variables at exit. |
Sorry, something went wrong.
|
I wrote PR #18135 which doesn't introduce a backward incompatible change. I close this PR. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Environment variables set by os.environ and os.putenv() are now
cleared at exit. Python manages their memory which is released
at exit.
https://bugs.python.org/issue39395