]> granicus.if.org Git - python/commitdiff
bpo-28624: Add a test that checks that cwd parameter of Popen() accepts PathLike...
authorSayan Chowdhury <sayan.chowdhury2012@gmail.com>
Sun, 26 Feb 2017 17:06:10 +0000 (22:36 +0530)
committerBerker Peksag <berker.peksag@gmail.com>
Sun, 26 Feb 2017 17:06:10 +0000 (20:06 +0300)
Doc/library/subprocess.rst
Lib/test/test_subprocess.py
Misc/ACKS
Misc/NEWS

index e9ba15eec1c20bd687fe050424c88c61a32e3a4f..d0b2f9bff96b05b54ac14e6c0ea5670b1b0185e1 100644 (file)
@@ -466,9 +466,13 @@ functions.
       The *pass_fds* parameter was added.
 
    If *cwd* is not ``None``, the function changes the working directory to
-   *cwd* before executing the child.  In particular, the function looks for
-   *executable* (or for the first item in *args*) relative to *cwd* if the
-   executable path is a relative path.
+   *cwd* before executing the child.  *cwd* can be a :class:`str` and
+   :term:`path-like <path-like object>` object.  In particular, the function
+   looks for *executable* (or for the first item in *args*) relative to *cwd*
+   if the executable path is a relative path.
+
+   .. versionchanged:: 3.6
+      *cwd* parameter accepts a :term:`path-like object`.
 
    If *restore_signals* is true (the default) all signals that Python has set to
    SIG_IGN are restored to SIG_DFL in the child process before the exec.
index 812e7bf2cc8a7291017d564f264aed54b44421f5..8511207f0d6fa56b15f3469cffe7227ce17ac88c 100644 (file)
@@ -347,6 +347,16 @@ class ProcessTestCase(BaseTestCase):
         temp_dir = self._normalize_cwd(temp_dir)
         self._assert_cwd(temp_dir, sys.executable, cwd=temp_dir)
 
+    def test_cwd_with_pathlike(self):
+        temp_dir = tempfile.gettempdir()
+        temp_dir = self._normalize_cwd(temp_dir)
+
+        class _PathLikeObj:
+            def __fspath__(self):
+                return temp_dir
+
+        self._assert_cwd(temp_dir, sys.executable, cwd=_PathLikeObj())
+
     @unittest.skipIf(mswindows, "pending resolution of issue #15533")
     def test_cwd_with_relative_arg(self):
         # Check that Popen looks for args[0] relative to cwd if args[0]
index 1995adb371e97017c62f6685c7a5c2ab749493ca..b7f1282c69c0ce0e46cd471038e0ec4c7b63c051 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -269,6 +269,7 @@ Albert Chin-A-Young
 Adal Chiriliuc
 Matt Chisholm
 Lita Cho
+Sayan Chowdhury
 Anders Chrigström
 Tom Christiansen
 Renee Chu
index 8949ab4c75e7f6257c610cd0cb898a17140b78cf..283db49c99a1083d34ae3b0ae3fc9e9e018a92fd 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -249,6 +249,9 @@ Extension Modules
 Library
 -------
 
+- bpo-28624: Add a test that checks that cwd parameter of Popen() accepts
+  PathLike objects.  Patch by Sayan Chowdhury.
+
 - bpo-28518: Start a transaction implicitly before a DML statement.
   Patch by Aviv Palivoda.