| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
| |
Fix issue where `pathlib.Path.glob()` raised `OSError` when it encountered
a symlink to an overly long path.
(cherry picked from commit a33ce66dca57d4c36b1022fdf3b7e322f3203468)
Co-authored-by: Barney Gale <barney.gale@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(GH-93273)
When a `_PathParents` object has a drive or a root, the length of the
object is *one less* than than the length of `self._parts`, which resulted
in an off-by-one error when `path.parents[-n]` was fed through to
`self._parts[:-n - 1]`. In particular, `path.parents[-1]` was a malformed
path object with spooky properties.
This is addressed by adding `len(self)` to negative indices.
(cherry picked from commit f32e6b48d12834ba3bde01ec21c14da33abd26d6)
Co-authored-by: Barney Gale <barney.gale@gmail.com>
|
|
|
|
|
| |
(cherry picked from commit 87f849c775ca54f56ad60ebf96822b93bbd0029a)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
|
|
|
|
|
| |
(GH-92599)
This reverts commit a51baec9ce0eae2b4db069a55daf8f03be3ab2f4.
|
|
|
|
|
|
|
|
|
|
| |
We could try to remedy this by taking a slice, but we then run into an issue where the empty string will match altsep on POSIX. That rabbit hole could keep getting deeper.
A proper fix for the original issue involves making pathlib's path normalisation more configurable - in this case we want to retain trailing slashes, but in other we might want to preserve `./` prefixes, or elide `../` segments when we're sure we won't encounter symlinks.
This reverts commit ea2f5bcda1a392804487e6883be89fbad38a01a5.
(cherry picked from commit dcdf250d2de1428f7d8b4e9ecf51d2fd8200e21a)
Co-authored-by: Barney Gale <barney.gale@gmail.com>
|
|
|
|
|
|
|
| |
(GH-10349)
Now pathlib.Path.glob() **only** matches directories when the pattern ends in a path separator.
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
|
|
|
|
|
| |
In Python 3.9, Path.__exit__() was made a no-op and has never been documented.
Co-authored-by: Brett Cannon <brett@python.org>
|
|
|
| |
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Per Pitrou:
> The original intent for the “accessor” thing was to have a variant that did all accesses under a filesystem tree in a race condition-free way using openat and friends. It turned out to be much too hairy to actually implement, so was entirely abandoned, but the accessor abstraction was left there.
https://discuss.python.org/t/make-pathlib-extensible/3428/2
Accessors are:
- Lacking any internal purpose - '_NormalAccessor' is the only implementation
- Lacking any firm conceptual difference to `Path` objects themselves (inc. subclasses)
- Non-public, i.e. underscore prefixed - '_Accessor' and '_NormalAccessor'
- Unofficially used to implement customized `Path` objects, but once once [bpo-24132]() is addressed there will be a supported route for that.
This patch preserves all existing behaviour.
|
|
|
|
| |
Co-authored-by: Brett Cannon <brett@python.org>
Co-authored-by: Brian Helba <brian.helba@kitware.com>
|
|
|
|
| |
(GH-30822)
|
|
|
|
| |
`os.listdir()` doesn't return entries for `.` or `..`, so we don't need to
check for them here.
|
| |
|
|
|
|
|
|
|
| |
`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>
|
|
|
|
| |
(GH-26155)
|
| |
|
|
|
|
| |
unnecessarily (GH-25699)
|
|
|
|
|
| |
(GH-25264)
Also adds a new "strict" argument to realpath() to avoid changing the default behaviour of pathlib while sharing the implementation.
|
|
|
|
|
|
|
|
|
|
|
| |
`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()`.
|
|
|
|
| |
invalid filename (GH-25529)
|
|
|
| |
Previously we had identical behaviour but only allowed accessors to override os.open(). This change allows the override to also construct the IO wrapper as well.
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
accessor (GH-18834)
|
| |
|
|
|
|
| |
(GH-18864)
|
|
|
|
| |
modifying a path (GH-19342)
|
|
|
|
| |
accessor. (GH-18838)
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
See [PEP 597](https://www.python.org/dev/peps/pep-0597/).
* Add `-X warn_default_encoding` and `PYTHONWARNDEFAULTENCODING`.
* Add EncodingWarning
* Add io.text_encoding()
* open(), TextIOWrapper() emits EncodingWarning when encoding is omitted and warn_default_encoding is enabled.
* _pyio.TextIOWrapper() uses UTF-8 as fallback default encoding used when failed to import locale module. (used during building Python)
* bz2, configparser, gzip, lzma, pathlib, tempfile modules use io.text_encoding().
* What's new entry
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
| |
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)`.
|
|
|
|
|
|
|
|
|
| |
(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
|
| |
|
| |
|
|
|
|
|
| |
(GH-19611)
Co-authored-by: Sadhana Srinivasan <rotuna@Sadhanas-MBP.fritz.box>
|
|
|
|
| |
Add PurePath.with_stem()
|
|
|
|
| |
path accessor (GH-18836)
|
|
|
|
| |
`is_mount()` misbehave in `Path` subclasses. (GH-18839)
|
|
|
|
| |
the path accessor. (GH-18844)
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
| |
insufficient permissions (GH-18815)
Co-authored-by: Matt Wozniski <mwozniski@bloomberg.net>
|
|
|
|
| |
Path.rglob(). (GH-18372)
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
| |
Commit 6b5b013bcc22 ("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>
|
|
|
| |
https://bugs.python.org/issue38994
|
|
|
|
|
| |
(GH-17170)" (#17219)
This reverts commit 111772fc27cfe388bc060f019d68a3e33481ec65.
|
|
|
|
|
| |
Fix also the Path.symplink() method implementation for the case when
symlinks are not supported.
|
|
|
|
|
|
|
|
|
|
| |
Whenever I use `path.suffix` I have to check again whether it includes the dot or not. I decided to add it to the docstring so I won't have to keep checking.
https://bugs.python.org/issue38422
Automerge-Triggered-By: @pitrou
|
|
|
|
|
|
|
|
|
|
|
| |
This adds a "readlink" method to pathlib.Path objects that calls through
to os.readlink.
https://bugs.python.org/issue30618
Automerge-Triggered-By: @gpshead
|