summaryrefslogtreecommitdiffstats
path: root/Lib/pathlib.py
Commit message (Collapse)AuthorAgeFilesLines
* bpo-43970: Optimize Path.cwd() in pathlib by not instantiating a class ↵kfollstad2021-04-281-1/+1
| | | | unnecessarily (GH-25699)
* bpo-43757: Make pathlib use os.path.realpath() to resolve symlinks in a path ↵Barney Gale2021-04-281-95/+30
| | | | | (GH-25264) Also adds a new "strict" argument to realpath() to avoid changing the default behaviour of pathlib while sharing the implementation.
* bpo-39950: add `pathlib.Path.hardlink_to()` method that supersedes ↵Barney Gale2021-04-231-0/+15
| | | | | | | | | | | `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()`.
* bpo-35306: Avoid raising OSError from pathlib.Path.exists when passed an ↵Steve Dower2021-04-221-0/+1
| | | | invalid filename (GH-25529)
* bpo-40107: Switch to using io.open() for pathlib.Path.open() (GH-25240)Barney Gale2021-04-091-7/+3
| | | 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.
* bpo-39899: os.path.expanduser(): don't guess other Windows users' home ↵Barney Gale2021-04-071-45/+6
| | | | | | | 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.
* bpo-39659: Route calls from pathlib.Path to os.getcwd() via the path ↵Barney Gale2021-04-071-4/+6
| | | | accessor (GH-18834)
* bpo-42999: Expand and clarify pathlib.Path.link_to() documentation. (GH-24294)Barney Gale2021-04-071-8/+14
|
* bpo-39906: Add follow_symlinks parameter to pathlib.Path.stat() and chmod() ↵Barney Gale2021-04-071-14/+6
| | | | (GH-18864)
* bpo-40038: pathlib: remove partial support for preserving accessor when ↵Barney Gale2021-04-071-33/+8
| | | | modifying a path (GH-19342)
* bpo-39895: Move `pathlib.Path.touch()` implementation into the path ↵Barney Gale2021-04-071-24/+18
| | | | accessor. (GH-18838)
* bpo-39924: handle missing os functions more consistently in pathlib (GH-19220)Barney Gale2021-04-061-27/+16
|
* bpo-43510: Implement PEP 597 opt-in EncodingWarning. (GH-19481)Inada Naoki2021-03-291-0/+4
| | | | | | | | | | | 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
* Added support for negative indexes to PurePath.parents (GH-21799)Yaroslav Pankovych2020-11-231-1/+2
| | | | | | | | | | 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>
* bpo-35498: Added slice support to PathLib parents attribute. (GH-11165)Joshua Cannon2020-11-201-0/+2
| | | 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)`.
* bpo-23706: Add newline parameter to pathlib.Path.write_text (GH-22420) ↵Максим2020-10-211-2/+2
| | | | | | | | | (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
* bpo-40833: Clarify Path.rename doc-string regarding relative paths (GH-20554)Ram Rachum2020-10-031-5/+14
|
* bpo-33660: Fix PosixPath to resolve a relative path on rootDong-hee Na2020-08-271-1/+4
|
* bpo-23082: Better error message for PurePath.relative_to() from pathlib ↵Rotuna2020-05-251-1/+2
| | | | | (GH-19611) Co-authored-by: Sadhana Srinivasan <rotuna@Sadhanas-MBP.fritz.box>
* bpo-40148: Add PurePath.with_stem() (GH-19295)Tim Hoffmann2020-04-191-0/+4
| | | | Add PurePath.with_stem()
* bpo-39894: Route calls from pathlib.Path.samefile() to os.stat() via the ↵Barney Gale2020-04-171-1/+1
| | | | path accessor (GH-18836)
* bpo-39897: Remove needless `Path(self.parent)` call, which makes ↵Barney Gale2020-04-171-3/+2
| | | | `is_mount()` misbehave in `Path` subclasses. (GH-18839)
* bpo-39901: Move `pathlib.Path.owner()` and `group()` implementations into ↵Barney Gale2020-04-171-10/+16
| | | | the path accessor. (GH-18844)
* bpo-39682: make `pathlib.Path` immutable by removing (undocumented) support ↵Barney Gale2020-04-011-42/+9
| | | | | | 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.
* bpo-39916: Use os.scandir() as context manager in Path.glob(). (GH-18880)Serhiy Storchaka2020-03-111-2/+4
|
* bpo-38894: Fix pathlib.Path.glob in the presence of symlinks and ↵Pablo Galindo2020-03-071-13/+16
| | | | | insufficient permissions (GH-18815) Co-authored-by: Matt Wozniski <mwozniski@bloomberg.net>
* bpo-39567: Add audit for os.walk(), os.fwalk(), Path.glob() and ↵Serhiy Storchaka2020-02-121-0/+2
| | | | Path.rglob(). (GH-18372)
* bpo-38883: Don't use POSIX `$HOME` in `pathlib.Path.home/expanduser` on ↵Christoph Reiter2020-01-281-3/+1
| | | | | | | | | 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.
* bpo-38811: Check for presence of os.link method in pathlib (GH-17225)Toke Høiland-Jørgensen2019-12-161-1/+6
| | | | | | | | | | | 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>
* bpo-38994: Implement __class_getitem__ for PathLike (GH-17498)Batuhan Taşkaya2019-12-081-0/+3
| | | https://bugs.python.org/issue38994
* Revert "bpo-38811: Check for presence of os.link method in pathlib. ↵Victor Stinner2019-11-181-7/+1
| | | | | (GH-17170)" (#17219) This reverts commit 111772fc27cfe388bc060f019d68a3e33481ec65.
* bpo-38811: Check for presence of os.link method in pathlib. (GH-17170)Toke Høiland-Jørgensen2019-11-171-1/+7
| | | | | Fix also the Path.symplink() method implementation for the case when symlinks are not supported.
* bpo-38422: Clarify docstrings of pathlib suffix(es) (GH-16679)Ram Rachum2019-11-021-2/+10
| | | | | | | | | | 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
* bpo-30618: add readlink to pathlib.Path (GH-8285)Girts2019-10-231-0/+9
| | | | | | | | | | | This adds a "readlink" method to pathlib.Path objects that calls through to os.readlink. https://bugs.python.org/issue30618 Automerge-Triggered-By: @gpshead
* bpo-31202: Preserve case of literal parts in Path.glob() on Windows. (GH-16860)Serhiy Storchaka2019-10-211-18/+20
|
* bpo-31163: Added return values to pathlib.Path instance's rename and replace ↵hui shang2019-09-111-2/+6
| | | | | methods. (GH-13582) * bpo-31163: Added return values to pathlib.Path instance's rename and replace methods.
* bpo-37689: add Path.is_relative_to() method (GH-14982)Hai Shi2019-08-131-0/+9
|
* bpo-34775: Return NotImplemented in PurePath division. (GH-9509)aiudirog2019-08-081-2/+8
|
* bpo-36035: fix Path.rglob for broken links (GH-11988)Jörg Stucke2019-05-211-3/+10
| | | Links creating an infinite symlink loop would raise an exception.
* bpo-33123: pathlib: Add missing_ok parameter to Path.unlink (GH-6191)‮zlohhcuB treboR2019-05-151-2/+6
| | | | | | 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
* bpo-36766: Typos in docs and code comments (GH-13116)penguindustin2019-05-061-1/+1
|
* bpo-26978: Implement pathlib.Path.link_to (Using os.link) (GH-12990)Joannah Nanjekye2019-05-041-0/+10
|
* bpo-22062: Updated docstring and documentation for pathlib (GH-8519)Eivind Teig2019-02-111-2/+3
| | | | | | Original patch by Mike Short https://bugs.python.org/issue22062
* bpo-35692: pathlib no longer raises when checking file and directory ↵Steve Dower2019-02-041-9/+18
| | | | existence on drives that are not ready (GH-11746)
* bpo-33721: Make some os.path functions and pathlib.Path methods be tolerant ↵Serhiy Storchaka2018-09-181-0/+24
| | | | | | | | | | 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.
* bpo-33635: Handling Bad file descriptor in Path.is_file and related. (GH-8542)Przemysław Spodymek2018-08-271-10/+19
|
* bpo-34333: Fix %-formatting in Path.with_suffix() (GH-8663)Berker Peksag2018-08-111-1/+1
|
* bpo-34329: Doc'd how to remove suffix of pathlib.Path() (GH-8655)Stefan Otte2018-08-031-2/+4
|
* bpo-31972: Improve docstrings for pathlib classes (#5310)chason2018-02-181-1/+29
|
* bpo-30152: Reduce the number of imports for argparse. (#1269)Serhiy Storchaka2017-09-251-1/+1
|