Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Closed
vstinner wants to merge 1 commit into
python:masterpython/cpython:masterfrom
vstinner:unsetenv_win2Copy head branch name to clipboard
Closed

bpo-39413: Use _wputenv(), not SetEnvironmentVariableW()#18107
vstinner wants to merge 1 commit into
python:masterpython/cpython:masterfrom
vstinner:unsetenv_win2Copy head branch name to clipboard

Conversation

@vstinner

@vstinner vstinner commented Jan 21, 2020

Copy link
Copy Markdown
Member

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
Copy Markdown
Member Author

cc @serhiy-storchaka @eryksun

Comment thread Lib/os.py
_unsetenv = unsetenv
except NameError:
_unsetenv = lambda key: _putenv(key, "")
if name == 'nt':

Copy link
Copy Markdown
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
Copy Markdown
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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.