File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree 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 @@ -917,6 +917,9 @@ Core and Builtins
917917Library
918918-------
919919
920+ - Issue #28624: Make the `cwd` argument to `subprocess.Popen` accept a
921+ `PathLike`.
922+
920923- Issue #29085: Allow random.Random.seed() to use high quality OS randomness
921924 rather than the pid and time.
922925
You can’t perform that action at this time.
0 commit comments