-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
bpo-30374: Fixed several bugs in win_add2path.py #1645
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
Conversation
* Discard the DEFAULT "%PATH%" value. * Delete wrong `os.path.isdir()`. * Add absolute path instead of `%APPDATA%...` if the type of PATH is `REG_SZ`. * Broadcast a `WM_SETTINGCHANG` message after the change of env vars. * Add codes to deal with possible errors.
@neEverett, thanks for your PR! By analyzing the history of the files in this pull request, we identified @benjaminp, @tiran and @birkenfeld to be potential reviewers. |
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.
Thanks for this! Overall they are good looking changes, just a few loose ends to tidy up.
Tools/scripts/win_add2path.py
Outdated
@@ -11,43 +11,67 @@ | |||
import site | |||
import os | |||
import winreg | |||
import ctypes |
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.
Put in alphabetical order
Tools/scripts/win_add2path.py
Outdated
envpath, dtype = winreg.QueryValueEx(key, PATH) | ||
except FileNotFoundError: | ||
envpath, dtype = "", winreg.REG_EXPAND_SZ | ||
pass |
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.
Unnecessary pass
Tools/scripts/win_add2path.py
Outdated
except: | ||
raise OSError("Failed to load PATH value") | ||
|
||
if hasattr(site, "USER_SITE") and dtype == winreg.REG_EXPAND_SZ: |
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.
This hasattr
check doesn't apply to the subsequent elif
block, or rather, if the first check here fails then we may end up crashing in the elif block.
Fixed the problems mentioned here: python#1645
Fixed the problems mentioned here: python#1645
Closing and reopening to retrigger tests. |
This PR is stale because it has been open for 30 days with no activity. |
This PR is stale because it has been open for 30 days with no activity. |
Closing as win_add2path.py was removed in #98167. thanks |
DEFAULT = "%PATH%"
. The system PATH is effective to all users[1] so adding "%PATH%" in user PATH is unnecessary.os.path.isdir()
always return False because the input path includes"%APPDATA%"
and also because the USER_SITE directory does not yet exist when Python is just installed. It is now deleted to make paths be added correctly."%APPDATA%"
effective[2] . However this is not a good practice (brought forward by Eryk Sun in the issue). Now the script does not change the type of PATH. If it's REG_SZ, the absolute path of%APPDATA%
will be added instead.WM_SETTINGCHANG
message[3] after the change of env vars.https://bugs.python.org/issue30374