Skip to content

Commit c7e3365

Browse files
lilydjwgDinoV
authored andcommitted
bpo-35246: fix support for path-like args in asyncio subprocess (pythonGH-13628)
Drop isinstance checks from create_subprocess_exec function and let subprocess module do them. https://bugs.python.org/issue35246 https://bugs.python.org/issue35246
1 parent cea62fa commit c7e3365

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

Lib/asyncio/base_events.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,11 +1605,6 @@ async def subprocess_exec(self, protocol_factory, program, *args,
16051605
raise ValueError("errors must be None")
16061606

16071607
popen_args = (program,) + args
1608-
for arg in popen_args:
1609-
if not isinstance(arg, (str, bytes)):
1610-
raise TypeError(
1611-
f"program arguments must be a bytes or text string, "
1612-
f"not {type(arg).__name__}")
16131608
protocol = protocol_factory()
16141609
debug_log = None
16151610
if self._debug:

Lib/test/test_asyncio/test_subprocess.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,17 @@ async def execute():
622622
self.loop.run_until_complete(execute())
623623

624624

625+
def test_create_subprocess_exec_with_path(self):
626+
async def execute():
627+
p = await subprocess.create_subprocess_exec(
628+
support.FakePath(sys.executable), '-c', 'pass')
629+
await p.wait()
630+
p = await subprocess.create_subprocess_exec(
631+
sys.executable, '-c', 'pass', support.FakePath('.'))
632+
await p.wait()
633+
634+
self.assertIsNone(self.loop.run_until_complete(execute()))
635+
625636
if sys.platform != 'win32':
626637
# Unix
627638
class SubprocessWatcherMixin(SubprocessMixin):
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Make :func:`asyncio.create_subprocess_exec` accept path-like arguments.

0 commit comments

Comments
 (0)