Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.4k
gh-101283: Try to load the fallback cmd.exe by an absolute path#101286
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes from7 commits
d122f14e96457cb26918e9a0fdbd091e970a3cbdb68dab7f11d8d4a69ed1758a2734a6407aa35f1dfcff880d443b34f99884cf94f9cbdfca8bfb11b86473daf1b441211ebd6925dcbb8fc085487e0670381aba86fecd606File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1480,7 +1480,23 @@ def _execute_child(self, args, executable, preexec_fn, close_fds, | ||
| if shell: | ||
| startupinfo.dwFlags |= _winapi.STARTF_USESHOWWINDOW | ||
| startupinfo.wShowWindow = _winapi.SW_HIDE | ||
| # gh-101283: with no full path, Windows looks into a | ||
| # current directory first so no plain "cmd.exe". | ||
arhadthedev marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| comspec = os.environ.get('ComSpec') | ||
eryksun marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| if not comspec: | ||
| system_drive = os.environ.get('SystemDrive') or 'C:' | ||
| system_root = os.environ.get('SystemRoot') or os.path.join( | ||
| system_drive, 'Windows') | ||
| comspec = os.path.join(system_root, 'System32', 'cmd.exe') | ||
arhadthedev marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| if not os.path.isfile(comspec): | ||
zooba marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page.
arhadthedev marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| # cmd.exe is missing, or the system environment | ||
| # variables are broken, or they're undefined and the | ||
| # system is installed into a non-standard location. | ||
| # This is highly unlikely, and we cannot help here. | ||
| ||
| comspec = 'cmd.exe' | ||
| if not executable and os.path.isabs(comspec): | ||
arhadthedev marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| executable = comspec | ||
| args = '{} /c "{}"'.format (comspec, args) | ||
| if cwd is not None: | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| Windows version of:meth:`subprocess.Popen.__init__` with | ||
| ``shell=True`` made its shell search algorithm protected from dropping | ||
| a program named ``cmd.exe`` into a current directory. Now the current | ||
| directory is used as the last resort if system environment variables | ||
arhadthedev marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| are totally stripped and Windows is installed not into ``C\Windows``. | ||
arhadthedev marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| Patch by Eryk Sun. | ||
eryksun marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page.
| ||