Skip to content

Commit

Permalink
bpo-35246: fix support for path-like args in asyncio subprocess (GH-1…
Browse files Browse the repository at this point in the history
…3628)

Drop isinstance checks from create_subprocess_exec function and let
subprocess module do them.

https://bugs.python.org/issue35246


https://bugs.python.org/issue35246
  • Loading branch information
lilydjwg authored and miss-islington committed May 29, 2019
1 parent e1f95e7 commit 744c08a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
5 changes: 0 additions & 5 deletions Lib/asyncio/base_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -1605,11 +1605,6 @@ async def subprocess_exec(self, protocol_factory, program, *args,
raise ValueError("errors must be None")

popen_args = (program,) + args
for arg in popen_args:
if not isinstance(arg, (str, bytes)):
raise TypeError(
f"program arguments must be a bytes or text string, "
f"not {type(arg).__name__}")
protocol = protocol_factory()
debug_log = None
if self._debug:
Expand Down
11 changes: 11 additions & 0 deletions Lib/test/test_asyncio/test_subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,17 @@ async def execute():
self.loop.run_until_complete(execute())


def test_create_subprocess_exec_with_path(self):
async def execute():
p = await subprocess.create_subprocess_exec(
support.FakePath(sys.executable), '-c', 'pass')
await p.wait()
p = await subprocess.create_subprocess_exec(
sys.executable, '-c', 'pass', support.FakePath('.'))
await p.wait()

self.assertIsNone(self.loop.run_until_complete(execute()))

if sys.platform != 'win32':
# Unix
class SubprocessWatcherMixin(SubprocessMixin):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Make :func:`asyncio.create_subprocess_exec` accept path-like arguments.

0 comments on commit 744c08a

Please sign in to comment.