[Python-checkins] bpo-35246: fix support for path-like args in asyncio subprocess (GH-13628)

Miss Islington (bot) webhook-mailer at python.org
Wed May 29 02:51:06 EDT 2019


https://github.com/python/cpython/commit/744c08a9c75a1a53b7a6521fcee3e7c513919ff9
commit: 744c08a9c75a1a53b7a6521fcee3e7c513919ff9
branch: master
author: 依云 <lilydjwg at gmail.com>
committer: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
date: 2019-05-28T23:50:59-07:00
summary:

bpo-35246: fix support for path-like args in asyncio subprocess (GH-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

files:
A Misc/NEWS.d/next/Library/2019-05-28-23-17-35.bpo-35246.oXT21d.rst
M Lib/asyncio/base_events.py
M Lib/test/test_asyncio/test_subprocess.py

diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py
index 68105eec8132..e0025397fa8a 100644
--- a/Lib/asyncio/base_events.py
+++ b/Lib/asyncio/base_events.py
@@ -1605,11 +1605,6 @@ def _log_subprocess(self, msg, stdin, stdout, stderr):
             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:
diff --git a/Lib/test/test_asyncio/test_subprocess.py b/Lib/test/test_asyncio/test_subprocess.py
index f1ab039ad663..7d72e6cde4e7 100644
--- a/Lib/test/test_asyncio/test_subprocess.py
+++ b/Lib/test/test_asyncio/test_subprocess.py
@@ -622,6 +622,17 @@ def test_create_subprocess_shell_text_mode_fails(self):
         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):
diff --git a/Misc/NEWS.d/next/Library/2019-05-28-23-17-35.bpo-35246.oXT21d.rst b/Misc/NEWS.d/next/Library/2019-05-28-23-17-35.bpo-35246.oXT21d.rst
new file mode 100644
index 000000000000..39d4469cd101
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2019-05-28-23-17-35.bpo-35246.oXT21d.rst
@@ -0,0 +1 @@
+Make :func:`asyncio.create_subprocess_exec` accept path-like arguments.



More information about the Python-checkins mailing list