File tree Expand file tree Collapse file tree 4 files changed +21
-3
lines changed
Expand file tree Collapse file tree 4 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -466,9 +466,13 @@ functions.
466466 The *pass_fds * parameter was added.
467467
468468 If *cwd * is not ``None ``, the function changes the working directory to
469- *cwd * before executing the child. In particular, the function looks for
470- *executable * (or for the first item in *args *) relative to *cwd * if the
471- executable path is a relative path.
469+ *cwd * before executing the child. *cwd * can be a :class: `str ` and
470+ :term: `path-like <path-like object> ` object. In particular, the function
471+ looks for *executable * (or for the first item in *args *) relative to *cwd *
472+ if the executable path is a relative path.
473+
474+ .. versionchanged :: 3.6
475+ *cwd * parameter accepts a :term: `path-like object `.
472476
473477 If *restore_signals * is true (the default) all signals that Python has set to
474478 SIG_IGN are restored to SIG_DFL in the child process before the exec.
Original file line number Diff line number Diff line change @@ -347,6 +347,16 @@ def test_cwd(self):
347347 temp_dir = self ._normalize_cwd (temp_dir )
348348 self ._assert_cwd (temp_dir , sys .executable , cwd = temp_dir )
349349
350+ def test_cwd_with_pathlike (self ):
351+ temp_dir = tempfile .gettempdir ()
352+ temp_dir = self ._normalize_cwd (temp_dir )
353+
354+ class _PathLikeObj :
355+ def __fspath__ (self ):
356+ return temp_dir
357+
358+ self ._assert_cwd (temp_dir , sys .executable , cwd = _PathLikeObj ())
359+
350360 @unittest .skipIf (mswindows , "pending resolution of issue #15533" )
351361 def test_cwd_with_relative_arg (self ):
352362 # Check that Popen looks for args[0] relative to cwd if args[0]
Original file line number Diff line number Diff line change @@ -269,6 +269,7 @@ Albert Chin-A-Young
269269Adal Chiriliuc
270270Matt Chisholm
271271Lita Cho
272+ Sayan Chowdhury
272273Anders Chrigström
273274Tom Christiansen
274275Renee Chu
Original file line number Diff line number Diff line change @@ -249,6 +249,9 @@ Extension Modules
249249Library
250250-------
251251
252+ - bpo-28624: Add a test that checks that cwd parameter of Popen() accepts
253+ PathLike objects. Patch by Sayan Chowdhury.
254+
252255- bpo-28518: Start a transaction implicitly before a DML statement.
253256 Patch by Aviv Palivoda.
254257
You can’t perform that action at this time.
0 commit comments