Closed
Description
Bug report
When passing an empty dictionary as env
to subprocess.run
(or Popen
), I get the following error:
Python 3.11.3 (tags/v3.11.3:f3909b8, Apr 4 2023, 23:49:59) [MSC v.1934 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess
>>> subprocess.run('c:\\msys64\\usr\\bin\\echo.exe', env={})
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\jhbaarnh\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 548, in run
with Popen(*popenargs, **kwargs) as process:
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\jhbaarnh\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 1024, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\jhbaarnh\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 1509, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [WinError 87] The parameter is incorrect
>>>
Environment
- Reproduced on the following CPython versions, all native windows builds:
- vanilla python 3.11.3
- vanilla Python 3.9.6
- Intel Python 3.9.16
- I can not reproduce the problem on any of the following:
- python 3.7.2, native Windows build and MSYS build (did not try newer MSYS)
- any linux
Linked PRs
- gh-105436: the environment block should end with two zero-valued wchar_t values #105495
- [3.12] gh-105436: The environment block should end with two null wchar_t values (GH-105495) #105700
- [3.11] gh-105436: The environment block should end with two null wchar_t values (GH-105495) #105701
- gh-105436: Ignore unrelated errors when checking empty env #105742
- [3.12] gh-105436: Ignore unrelated errors when checking empty env (GH-105742) #105756
- [3.11] gh-105436: Ignore unrelated errors when checking empty env (GH-105742) #105757