Skip to content
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

bpo-39413: Use _wputenv(), not SetEnvironmentVariableW() #18107

Closed
wants to merge 1 commit into from
Closed

bpo-39413: Use _wputenv(), not SetEnvironmentVariableW() #18107

wants to merge 1 commit into from

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Jan 21, 2020

Don't implement os.unsetenv() in C using
SetEnvironmentVariableW(name, NULL) anymore, but implement it in
Python as os.putenv(name, ""). _wputenv() is preferred since it
updates the CRT, whereas SetEnvironmentVariableW(name, NULL) does
not.

Replace also lambda functions with regular functions to get named
functions, to ease debug.

https://bugs.python.org/issue39413

Don't implement os.unsetenv() in C using
SetEnvironmentVariableW(name, NULL) anymore, but implement it in
Python as os.putenv(name, ""). _wputenv() is preferred since it
updates the CRT, whereas SetEnvironmentVariableW(name, NULL) does
not.

Replace also lambda functions with regular functions to get named
functions, to ease debug.
@vstinner
Copy link
Member Author

cc @serhiy-storchaka @eryksun

else:
if "putenv" not in __all__:
__all__.append("putenv")

try:
_unsetenv = unsetenv
except NameError:
_unsetenv = lambda key: _putenv(key, "")
if name == 'nt':
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks too complicated and obscure. Many lines are duplicated with small differences. Would not it be easier to implement nt.unsetenv() on C?

@vstinner
Copy link
Member Author

@serhiy-storchaka: "This looks too complicated and obscure. Many lines are duplicated with small differences. Would not it be easier to implement nt.unsetenv() on C?"

Ok, I wrote PR #18115 instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants