Commit Graph

123 Commits

Author SHA1 Message Date
Christian Clauss 745c9d9dfc
Fix typos in the Lib directory (GH-28775)
Fix typos in the Lib directory as identified by codespell.

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2021-10-06 16:13:48 -07:00
Barney Gale 56c1f6d7ed
bpo-27827: identify a greater range of reserved filename on Windows. (GH-26698)
`pathlib.PureWindowsPath.is_reserved()` now identifies as reserved
filenames with trailing spaces or colons.

Co-authored-by: Barney Gale <barney.gale@foundry.com>
Co-authored-by: Eryk Sun <eryksun@gmail.com>
2021-07-28 16:28:14 +02:00
Barney Gale 18f41c04ff
bpo-38671: Add test that `pathlib.Path.resolve()` returns an absolute path. (GH-26184)
Issue should be fixed in bpo-43757

Co-Authored-by: Tzu-ping Chung <uranusjr@gmail.com>
2021-05-20 18:41:33 +02:00
Barney Gale 1a08c5ac49
bpo-39950: Fix deprecation warning in test for `pathlib.Path.link_to()` (GH-26155) 2021-05-16 00:15:25 -07:00
Barney Gale f24e2e5464
bpo-39950: add `pathlib.Path.hardlink_to()` method that supersedes `link_to()` (GH-18909)
The argument order of `link_to()` is reversed compared to what one may expect, so:

    a.link_to(b)

Might be expected to create *a* as a link to *b*, in fact it creates *b* as a link to *a*, making it function more like a "link from". This doesn't match `symlink_to()` nor the documentation and doesn't seem to be the original author's intent.

This PR deprecates `link_to()` and introduces `hardlink_to()`, which has the same argument order as `symlink_to()`.
2021-04-23 13:48:52 -07:00
Barney Gale 3f3d82b848
bpo-39899: os.path.expanduser(): don't guess other Windows users' home directories if the basename of the current user's home directory doesn't match their username. (GH-18841)
This makes `ntpath.expanduser()` match `pathlib.Path.expanduser()` in this regard, and is more in line with `posixpath.expanduser()`'s cautious approach.

Also remove the near-duplicate implementation of `expanduser()` in pathlib, and by doing so fix a bug where KeyError could be raised when expanding another user's home directory.
2021-04-07 23:50:13 +01:00
Barney Gale abf964942f
bpo-39906: Add follow_symlinks parameter to pathlib.Path.stat() and chmod() (GH-18864) 2021-04-07 16:53:39 +01:00
pxinwr b230409f21
bpo-31904: Skip os.path.expanduser() tests on VxWorks (GH-23776) 2020-12-15 22:24:00 +01:00
pxinwr 6a273fdc2a
bpo-31904: skip some tests related to fifo on VxWorks (GH-23473)
On VxWork RTOS, FIFO must be created under directory "/fifos/". Some test cases related to fifo is invalid on VxWorks. So skip them.
2020-11-28 14:06:36 -08:00
Yaroslav Pankovych 79d2e62c00
Added support for negative indexes to PurePath.parents (GH-21799)
This commit also fixes up some of the overlapping documentation changed
in bpo-35498, which added support for indexing with slices.

Fixes bpo-21041.
https://bugs.python.org/issue21041

Co-authored-by: Paul Ganssle <p.ganssle@gmail.com>
Co-authored-by: Rémi Lapeyre <remi.lapeyre@henki.fr>
2020-11-23 15:06:22 -05:00
Joshua Cannon 4520584483
bpo-35498: Added slice support to PathLib parents attribute. (GH-11165)
Added slice support to the `pathlib.Path.parents` sequence. For a `Path` `p`, slices of `p.parents` should return the same thing as slices of `tuple(p.parents)`.
2020-11-20 10:40:39 -05:00
Максим 5f22741340
bpo-23706: Add newline parameter to pathlib.Path.write_text (GH-22420) (GH-22420)
* Add _newline_ parameter to `pathlib.Path.write_text()`
* Update documentation of `pathlib.Path.write_text()`
* Add test case for `pathlib.Path.write_text()` calls with _newline_ parameter passed

Automerge-Triggered-By: GH:methane
2020-10-20 19:08:19 -07:00
Dong-hee Na 94ad6c674f bpo-33660: Fix PosixPath to resolve a relative path on root 2020-08-27 02:24:38 +02:00
Hai Shi bb0424b122
bpo-40275: Use new test.support helper submodules in tests (GH-21451) 2020-08-03 18:47:42 +02:00
Tim Hoffmann 8aea4b3605
bpo-40148: Add PurePath.with_stem() (GH-19295)
Add PurePath.with_stem()
2020-04-19 17:29:49 +02:00
Barney Gale 00002e6d8b
bpo-39682: make `pathlib.Path` immutable by removing (undocumented) support for "closing" a path by using it as a context manager (GH-18846)
Support for using a path as a context manager remains, and is now a no-op.
2020-04-01 16:10:51 +02:00
Pablo Galindo eb7560a73d
bpo-38894: Fix pathlib.Path.glob in the presence of symlinks and insufficient permissions (GH-18815)
Co-authored-by: Matt Wozniski <mwozniski@bloomberg.net>
2020-03-07 17:53:20 +00:00
Christoph Reiter c45a2aa9e2 bpo-38883: Don't use POSIX `$HOME` in `pathlib.Path.home/expanduser` on Windows (GH-17961)
In bpo-36264 os.path.expanduser was changed to ignore HOME on Windows.

Path.expanduser/home still honored HOME despite being documented as behaving the same
as os.path.expanduser. This makes them also ignore HOME so that both implementations
behave the same way again.
2020-01-28 20:41:50 +11:00
Toke Høiland-Jørgensen 092435e932 bpo-38811: Check for presence of os.link method in pathlib (GH-17225)
Commit 6b5b013bcc ("bpo-26978: Implement pathlib.Path.link_to (Using
os.link) (GH-12990)") introduced a new link_to method in pathlib. However,
this makes pathlib crash when the 'os' module is missing a 'link' method.

Fix this by checking for the presence of the 'link' method on pathlib
module import, and if it's not present, turn it into a runtime error like
those emitted when there is no lchmod() or symlink().

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
2019-12-16 13:23:55 +01:00
Batuhan Taşkaya 526606baf7 bpo-38994: Implement __class_getitem__ for PathLike (GH-17498)
https://bugs.python.org/issue38994
2019-12-08 12:31:15 -08:00
Victor Stinner 59c80889ff
Revert "bpo-38811: Check for presence of os.link method in pathlib. (GH-17170)" (#17219)
This reverts commit 111772fc27.
2019-11-18 12:26:37 +01:00
Toke Høiland-Jørgensen 111772fc27 bpo-38811: Check for presence of os.link method in pathlib. (GH-17170)
Fix also the Path.symplink() method implementation for the case when
symlinks are not supported.
2019-11-17 19:06:38 +02:00
Girts a01ba333af bpo-30618: add readlink to pathlib.Path (GH-8285)
This adds a "readlink" method to pathlib.Path objects that calls through
to os.readlink.


https://bugs.python.org/issue30618



Automerge-Triggered-By: @gpshead
2019-10-23 14:18:40 -07:00
Serhiy Storchaka 10ecbadb79
bpo-31202: Preserve case of literal parts in Path.glob() on Windows. (GH-16860) 2019-10-21 20:37:15 +03:00
Serhiy Storchaka f9dc2ad890 bpo-37935: Added tests for os.walk(), glob.iglob() and Path.glob() (GH-15956)
Test that they do not keep too many file descriptors open for the host OS in a reasonable test scenario.

See [bpo-37935](https://bugs.python.org/issue37935).
2019-09-12 13:54:48 +01:00
hui shang 088a09af4b bpo-31163: Added return values to pathlib.Path instance's rename and replace methods. (GH-13582)
* bpo-31163: Added return values to pathlib.Path instance's rename and replace methods.
2019-09-11 14:26:49 +01:00
Steve Dower 97d7906e30 bpo-38087: Fix case sensitivity in test_pathlib and test_ntpath (GH-15850) 2019-09-10 14:52:48 +01:00
Hai Shi 82642a052d bpo-37689: add Path.is_relative_to() method (GH-14982) 2019-08-13 21:54:02 +02:00
aiudirog 4c69be22df bpo-34775: Return NotImplemented in PurePath division. (GH-9509) 2019-08-08 08:41:10 +03:00
Jörg Stucke d5c120f7eb bpo-36035: fix Path.rglob for broken links (GH-11988)
Links creating an infinite symlink loop would raise an exception.
2019-05-21 19:44:40 +02:00
‮zlohhcuB treboR d9e006bcef bpo-33123: pathlib: Add missing_ok parameter to Path.unlink (GH-6191)
Similarly to how several pathlib file creation functions have an "exists_ok" parameter, we should introduce "missing_ok" that makes removal functions not raise an exception when a file or directory is already absent.  IMHO, this should cover Path.unlink and Path.rmdir.  Note, Path.resolve() has a "strict" parameter since 3.6 that does the same thing. Naming this of this new parameter tries to be consistent with the "exists_ok" parameter as that is more explicit about what it does (as opposed to "strict").


https://bugs.python.org/issue33123
2019-05-15 15:02:11 -07:00
Joannah Nanjekye 6b5b013bcc bpo-26978: Implement pathlib.Path.link_to (Using os.link) (GH-12990) 2019-05-04 17:27:10 +02:00
Anthony Shaw 83da926b89 bpo-35488: Add tests for ** glob matching in pathlib (GH-11171) 2019-01-06 12:31:29 -08:00
Steve Dower 0cd6391fd8
bpo-34977: Add Windows App Store package (GH-11027)
Also adds the PC/layout script for generating layouts on Windows.
2018-12-10 18:52:57 -08:00
Victor Stinner cb0b78a070
Revert "bpo-34977: Add Windows App Store package (GH-10245)" (GH-11019)
This reverts commit 468a15aaf9.
2018-12-07 12:57:43 +01:00
Steve Dower 468a15aaf9
bpo-34977: Add Windows App Store package (GH-10245) 2018-12-06 21:09:20 -08:00
Serhiy Storchaka 0185f34ddc
bpo-33721: Make some os.path functions and pathlib.Path methods be tolerant to invalid paths. (#7695)
Such functions as os.path.exists(), os.path.lexists(), os.path.isdir(),
os.path.isfile(), os.path.islink(), and os.path.ismount() now return False
instead of raising ValueError or its subclasses UnicodeEncodeError
and UnicodeDecodeError for paths that contain characters or bytes
unrepresentative at the OS level.
2018-09-18 11:28:51 +03:00
Przemysław Spodymek 216b745eaf bpo-33635: Handling Bad file descriptor in Path.is_file and related. (GH-8542) 2018-08-27 14:33:45 -07:00
Berker Peksag 423d05f6f5
bpo-34333: Fix %-formatting in Path.with_suffix() (GH-8663) 2018-08-11 08:45:06 +03:00
Steve Dower e5f41d2f1e
bpo-33522: Enable CI builds on Visual Studio Team Services (#6865) 2018-05-16 17:50:29 -04:00
Anders Kaseorg 5c0d462689 bpo-32601: Let test_expanduser use the same user if no others found. (GH-5246)
This happens in the NixOS build sandbox, for example, where the only
other user is nobody with home directory /.
2018-05-14 17:00:37 +03:00
Serhiy Storchaka b21d155f57
bpo-32964: Reuse a testing implementation of the path protocol in tests. (#5930) 2018-03-02 11:53:51 +02:00
xdegaye 92c2ca7633
bpo-28759: Skip some tests on PermissionError raised by Android (GH-4350)
Access to mkfifo(), mknod() and hard link creation is controled
by SELinux on Android.
Also remove test.support.android_not_root.
2017-11-12 17:31:07 +01:00
Cooper Lees 173ff4a58a bpo-30897: Add is_mount() to pathlib.Path (#2669)
* Add in is_mount() call to pathlib.Path similiar to os.path.ismount(path)
* Add tests for is_mount()
2017-08-01 15:35:45 -07:00
Antoine Pietri add98eb4fe bpo-30177: pathlib: include the full path in resolve(strict=False) (#1893) 2017-06-07 08:29:17 -07:00
Serhiy Storchaka 2e576f5aec bpo-30144: Import collections ABC from collections.abc rather than collections. (#1263) 2017-04-24 09:05:00 +03:00
Armin Rigo 22a594a004 bpo-29694: race condition in pathlib mkdir with flags parents=True (GH-1089) 2017-04-13 11:08:15 -07:00
Vajrasky Kok ec1f5df46e bpo-19791: Use functions from test support to check the symlink support. (GH-822) 2017-03-28 12:32:35 -07:00
Serhiy Storchaka af7b9ec5c8 bpo-25803: Avoid incorrect errors raised by Path.mkdir(exist_ok=True) (#805)
when the OS gives priority to errors such as EACCES over EEXIST.
2017-03-24 20:51:53 +02:00
Steve Dower 1add96f1b6 Issue #29416: Prevent infinite loop in pathlib.Path.mkdir 2017-02-04 14:55:16 -08:00