diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-06-03 21:57:54 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-03 21:57:54 (GMT) |
commit | 9f101c23a41e739f5f80cf38419df1281835d452 (patch) | |
tree | e05dc572a9c2ab713dc808a1eb063964d2ae9cb6 /Lib/tracemalloc.py | |
parent | e4113be63c27faf52c5ce79f1afa3b9f6e33de46 (diff) | |
download | cpython-9f101c23a41e739f5f80cf38419df1281835d452.zip cpython-9f101c23a41e739f5f80cf38419df1281835d452.tar.gz cpython-9f101c23a41e739f5f80cf38419df1281835d452.tar.bz2 |
gh-93156 - fix negative indexing into absolute `pathlib.PurePath().parents` (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>
Diffstat (limited to 'Lib/tracemalloc.py')
0 files changed, 0 insertions, 0 deletions