diff --git a/tests/test_process.py b/tests/test_process.py index e2d3269b..aa7def56 100644 --- a/tests/test_process.py +++ b/tests/test_process.py @@ -135,6 +135,21 @@ async def test(): self.loop.run_until_complete(test()) + @unittest.skipIf(sys.version_info < (3, 8, 0), + "3.5 to 3.7 does not support path-like objects " + "in the asyncio subprocess API") + def test_process_executable_2(self): + async def test(): + proc = await asyncio.create_subprocess_exec( + pathlib.Path(sys.executable), + b'-W', b'ignore', b'-c', b'print("spam")', + stdout=subprocess.PIPE) + + out, err = await proc.communicate() + self.assertEqual(out, b'spam\n') + + self.loop.run_until_complete(test()) + def test_process_pid_1(self): async def test(): prog = '''\ diff --git a/uvloop/handles/process.pyx b/uvloop/handles/process.pyx index f2e0f58b..89cd26f0 100644 --- a/uvloop/handles/process.pyx +++ b/uvloop/handles/process.pyx @@ -284,6 +284,13 @@ cdef class UVProcess(UVHandle): self.__args = args.copy() for i in range(an): arg = args[i] + try: + fspath = type(arg).__fspath__ + except AttributeError: + pass + else: + arg = fspath(arg) + if isinstance(arg, str): self.__args[i] = PyUnicode_EncodeFSDefault(arg) elif not isinstance(arg, bytes):