32-bit Python 3.12.7 subprocess.run() cannot run executables from Windows\System32
未关闭
还没有人认领这个 Issue。
OS-windows
type-bug
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 36k
- PR 合并指标
- PR 指标待抓取
描述
Bug report
Bug description:
PS C:\> py -V:3.12-32 -c "import subprocess; subprocess.run(['ssh'])"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\Brecht Machiels\AppData\Local\Programs\Python\Python312-32\Lib\subprocess.py", line 548, in run
with Popen(*popenargs, **kwargs) as process:
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Brecht Machiels\AppData\Local\Programs\Python\Python312-32\Lib\subprocess.py", line 1026, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\Brecht Machiels\AppData\Local\Programs\Python\Python312-32\Lib\subprocess.py", line 1538, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [WinError 2] The system cannot find the file specified
This does work in the 64-bit Python 3.12.7 (after renaming vcruntime140.dll; see #125872):
PS C:\> py -V:3.12 -c "import subprocess; subprocess.run(['ssh'])"
usage: ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-B bind_interface]
[-b bind_address] [-c cipher_spec] [-D [bind_address:]port]
[-E log_file] [-e escape_char] [-F configfile] [-I pkcs11]
[-i identity_file] [-J [user@]host[:port]] [-L address]
[-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]
[-Q query_option] [-R address] [-S ctl_path] [-W host:port]
[-w local_tun[:remote_tun]] destination [command [argument ...]]
I'm assuming that this is because ssh.exe is an ARM executable. Using file in a Git Bash shell:
$ file "C:\Windows\System32\OpenSSH\ssh.exe"
C:\Windows\System32\OpenSSH\ssh.exe: PE32+ executable (console) Aarch64, for MS Windows, 6 sections
Calling an amd64 git does work:
PS C:\> py -V:3.12-32 -c "import subprocess; subprocess.run(['git', 'version'])"
git version 2.47.0.windows.1
$ file "C:\Program Files\Git\cmd\git.exe"
C:\Program Files\Git\cmd\git.exe: PE32+ executable (console) x86-64, for MS Windows, 13 sections
CPython versions tested on:
3.12
Operating systems tested on:
Windows 11 ARM
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
在 Windows 11 ARM 上使用 32 位 Python 3.12 命令重现该故障,然后检查 Lib/subprocess.py 中 Popen 和 _execute_child 附近的代码,尤其是 _winapi.CreateProcess 调用。将其与成功的 64 位和 amd64 Git 情况进行比较;当 subprocess.run(['ssh']) 能够在报告的配置中启动 Windows System32 可执行文件时,即视为完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- operating-systems
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100