bpo-28624: Add a test that checks that cwd parameter of Popen() accep… · python/cpython@d5c11f7 (original) (raw)
4 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -466,9 +466,13 @@ functions. | ||
466 | 466 | The *pass_fds* parameter was added. |
467 | 467 | |
468 | 468 | 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 ` 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`. | |
472 | 476 | |
473 | 477 | If *restore_signals* is true (the default) all signals that Python has set to |
474 | 478 | 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): | ||
347 | 347 | temp_dir = self._normalize_cwd(temp_dir) |
348 | 348 | self._assert_cwd(temp_dir, sys.executable, cwd=temp_dir) |
349 | 349 | |
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 | + | |
350 | 360 | @unittest.skipIf(mswindows, "pending resolution of issue #15533") |
351 | 361 | def test_cwd_with_relative_arg(self): |
352 | 362 | # 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 | ||
269 | 269 | Adal Chiriliuc |
270 | 270 | Matt Chisholm |
271 | 271 | Lita Cho |
272 | +Sayan Chowdhury | |
272 | 273 | Anders Chrigström |
273 | 274 | Tom Christiansen |
274 | 275 | Renee Chu |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -249,6 +249,9 @@ Extension Modules | ||
249 | 249 | Library |
250 | 250 | ------- |
251 | 251 | |
252 | +- bpo-28624: Add a test that checks that cwd parameter of Popen() accepts | |
253 | + PathLike objects. Patch by Sayan Chowdhury. | |
254 | + | |
252 | 255 | - bpo-28518: Start a transaction implicitly before a DML statement. |
253 | 256 | Patch by Aviv Palivoda. |
254 | 257 |