Skip to content
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

create_subprocess_exec should treat env={} as empty environment (#439) #454

Merged
merged 5 commits into from
Aug 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions tests/test_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,22 @@ async def test():

self.loop.run_until_complete(test())

def test_process_env_2(self):
async def test():
cmd = 'env'
env = {} # empty environment
proc = await asyncio.create_subprocess_exec(
cmd,
env=env,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)

out, _ = await proc.communicate()
self.assertEqual(out, b'')
self.assertEqual(proc.returncode, 0)

self.loop.run_until_complete(test())

def test_process_cwd_1(self):
async def test():
cmd = 'pwd'
Expand Down
5 changes: 1 addition & 4 deletions uvloop/handles/process.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,6 @@ cdef class UVProcess(UVHandle):

char **ret

if UVLOOP_DEBUG:
assert arr_len > 0

ret = <char **>PyMem_RawMalloc((arr_len + 1) * sizeof(char *))
if ret is NULL:
raise MemoryError()
Expand Down Expand Up @@ -285,7 +282,7 @@ cdef class UVProcess(UVHandle):
self.uv_opt_args = self.__to_cstring_array(self.__args)

cdef _init_env(self, dict env):
if env is not None and len(env):
if env is not None:
self.__env = list()
for key in env:
val = env[key]
Expand Down