| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -131,10 +131,11 @@ we also call *flavours*: | |||
| 131 | 131 | >>> PurePath(Path('foo'), Path('bar')) | |
| 132 | 132 | PurePosixPath('foo/bar') | |
| 133 | 133 | ||
| 134 | - When *pathsegments* is empty, the current directory is assumed:: | ||
| 134 | + When *pathsegments* is empty or consists only of empty strings, | ||
| 135 | + the current directory is assumed:: | ||
| 135 | 136 | ||
| 136 | - >>> PurePath() | ||
| 137 | - PurePosixPath('.') | ||
| 137 | + >>> PurePath(), PurePath('') | ||
| 138 | + (PurePosixPath('.'), PurePosixPath('.')) | ||
| 138 | 139 | ||
| 139 | 140 | If a segment is an absolute path, all previous segments are ignored | |
| 140 | 141 | (like :func:`os.path.join`):: | |
@@ -1040,15 +1041,17 @@ Querying file type and status | |||
| 1040 | 1041 | ||
| 1041 | 1042 | .. method:: Path.exists(*, follow_symlinks=True) | |
| 1042 | 1043 | ||
| 1043 | - Return ``True`` if the path points to an existing file or directory. | ||
| 1044 | - ``False`` will be returned if the path is invalid, inaccessible or missing. | ||
| 1044 | + Return ``True`` if the path points to an existing file or directory and | ||
| 1045 | + ``False`` if the path is invalid, inaccessible or missing. | ||
| 1045 | 1046 | Use :meth:`Path.stat` to distinguish between these cases. | |
| 1046 | 1047 | ||
| 1047 | 1048 | This method normally follows symlinks; to check if a symlink exists, add | |
| 1048 | 1049 | the argument ``follow_symlinks=False``. | |
| 1049 | 1050 | ||
| 1050 | 1051 | :: | |
| 1051 | 1052 | ||
| 1053 | + >>> Path('').exists() # The current directory. | ||
| 1054 | + True | ||
| 1052 | 1055 | >>> Path('.').exists() | |
| 1053 | 1056 | True | |
| 1054 | 1057 | >>> Path('setup.py').exists() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -447,14 +447,15 @@ def test_long_task_name_is_truncated(self): | |||
| 447 | 447 | async def main(): | |
| 448 | 448 | asyncio.create_task(asyncio.sleep(10_000), name="x" * 300) | |
| 449 | 449 | await asyncio.sleep(0) | |
| 450 | - return [ | ||
| 450 | + names = [ | ||
| 451 | 451 | task.task_name | |
| 452 | 452 | for info in RemoteUnwinder(os.getpid()).get_all_awaited_by() | |
| 453 | 453 | for task in info.awaited_by | |
| 454 | 454 | ] | |
| 455 | + return asyncio.current_task().get_name(), names | ||
| 455 | 456 | ||
| 456 | - names = asyncio.run(main()) | ||
| 457 | - self.assertIn("Task-1", names) | ||
| 457 | + main_name, names = asyncio.run(main()) | ||
| 458 | + self.assertIn(main_name, names) | ||
| 458 | 459 | self.assertEqual([len(n) for n in names if n.startswith("x")], [255]) | |
| 459 | 460 | ||
| 460 | 461 | @skip_if_not_supported | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -552,11 +552,7 @@ def raiser(fn, *args, **kwargs): | |||
| 552 | 552 | os.lstat = orig_lstat | |
| 553 | 553 | ||
| 554 | 554 | def test_rmtree_uses_safe_fd_version_if_available(self): | |
| 555 | - _use_fd_functions = ({os.open, os.stat, os.unlink, os.rmdir} <= | ||
| 556 | - os.supports_dir_fd and | ||
| 557 | - os.listdir in os.supports_fd and | ||
| 558 | - os.stat in os.supports_follow_symlinks) | ||
| 559 | - if _use_fd_functions: | ||
| 555 | + if shutil._use_fd_functions: | ||
| 560 | 556 | self.assertTrue(shutil.rmtree.avoids_symlink_attacks) | |
| 561 | 557 | tmp_dir = self.mkdtemp() | |
| 562 | 558 | d = os.path.join(tmp_dir, 'a') | |
| Back | FazBrowse Home | New Git URL |
0 commit comments