Closed
Description
- uvloop version: 0.14.0
- Python version: 3.8.2
- Platform: Linux & macOS
- Can you reproduce the bug with
PYTHONASYNCIODEBUG
in env?: yes - Does uvloop behave differently from vanilla asyncio? How?: yes -- this is what I'm going to report.
import asyncio
from pathlib import Path
async def do():
p = await asyncio.create_subprocess_exec(Path('/bin/ls'), '-l')
exit_code = await p.wait()
print('exited with', exit_code)
asyncio.run(do())
works fine, while
import asyncio
from pathlib import Path
import uvloop
async def do():
p = await asyncio.create_subprocess_exec(Path('/bin/ls'), '-l')
exit_code = await p.wait()
print('exited with', exit_code)
uvloop.install()
asyncio.run(do())
generates an error:
Traceback (most recent call last):
File "test-sub.py", line 13, in <module>
asyncio.run(do())
File "/Users/joongi/.pyenv/versions/3.8.2/lib/python3.8/asyncio/runners.py", line 43, in run
return loop.run_until_complete(main)
File "uvloop/loop.pyx", line 1456, in uvloop.loop.Loop.run_until_complete
File "test-sub.py", line 7, in do
p = await asyncio.create_subprocess_exec(Path('/bin/ls'), '-l')
File "/Users/joongi/.pyenv/versions/3.8.2/lib/python3.8/asyncio/subprocess.py", line 236, in create_subprocess_exec
transport, protocol = await loop.subprocess_exec(
File "uvloop/loop.pyx", line 2749, in subprocess_exec
File "uvloop/loop.pyx", line 2707, in __subprocess_run
File "uvloop/handles/process.pyx", line 596, in uvloop.loop.UVProcessTransport.new
File "uvloop/handles/process.pyx", line 60, in uvloop.loop.UVProcess._init
File "uvloop/handles/process.pyx", line 49, in uvloop.loop.UVProcess._init
File "uvloop/handles/process.pyx", line 247, in uvloop.loop.UVProcess._init_options
File "uvloop/handles/process.pyx", line 290, in uvloop.loop.UVProcess._init_args
TypeError: all args must be str or bytes
Since Python 3.6 on Linux and Python 3.8 on Windows, the standard subprocess module accepts path-like objects in addition to str and bytes. However, the official documentation for the asyncio's subprocess API does not mention this is also possible in the asyncio's subprocess API, but as internally it uses the subprocess standard module, so it does support path-like objects as demonstrated above.
I believe that uvloop need to replicate this behavior since its goal is a drop-in replacement for asyncio's vanilla loop.
Metadata
Metadata
Assignees
Labels
No labels