https://github.com/python/cpython
Revision b382bf50c53e6eab09f3e3bf0802ab052cb0289d authored by Miss Islington (bot) on 03 June 2022, 21:53:00 UTC, committed by GitHub on 03 June 2022, 21:53:00 UTC

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>
1 parent 9cdfd1b
History
Tip revision: b382bf50c53e6eab09f3e3bf0802ab052cb0289d authored by Miss Islington (bot) on 03 June 2022, 21:53:00 UTC
gh-93156 - fix negative indexing into absolute `pathlib.PurePath().parents` (GH-93273)
Tip revision: b382bf5
File Mode Size
.azure-pipelines
.github
Doc
Grammar
Include
Lib
Mac
Misc
Modules
Objects
PC
PCbuild
Parser
Programs
Python
Tools
.editorconfig -rw-r--r-- 181 bytes
.gitattributes -rw-r--r-- 1.8 KB
.gitignore -rw-r--r-- 2.3 KB
.travis.yml -rw-r--r-- 6.5 KB
CODE_OF_CONDUCT.md -rw-r--r-- 630 bytes
LICENSE -rw-r--r-- 13.6 KB
Makefile.pre.in -rw-r--r-- 71.6 KB
README.rst -rw-r--r-- 9.9 KB
aclocal.m4 -rw-r--r-- 22.3 KB
config.guess -rwxr-xr-x 48.2 KB
config.sub -rwxr-xr-x 34.4 KB
configure -rwxr-xr-x 512.4 KB
configure.ac -rw-r--r-- 174.7 KB
install-sh -rwxr-xr-x 15.0 KB
netlify.toml -rw-r--r-- 82 bytes
pyconfig.h.in -rw-r--r-- 45.5 KB
setup.py -rw-r--r-- 114.1 KB

README.rst

back to top