Skip to content

[3.11] gh-93156 - fix negative indexing into absolute pathlib.PurePath().parents (GH-93273) #93479

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 3, 2022

Conversation

miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Jun 3, 2022

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 f32e6b4)

Co-authored-by: Barney Gale [email protected]

Automerge-Triggered-By: GH:brettcannon

…h().parents` (pythonGH-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 f32e6b4)

Co-authored-by: Barney Gale <[email protected]>
@miss-islington
Copy link
Contributor Author

Status check is done, and it's a success ✅ .

@miss-islington
Copy link
Contributor Author

Status check is done, and it's a success ✅ .

1 similar comment
@miss-islington
Copy link
Contributor Author

Status check is done, and it's a success ✅ .

@bedevere-bot bedevere-bot added type-bug An unexpected behavior, bug, or error awaiting review labels Jun 3, 2022
@miss-islington
Copy link
Contributor Author

Status check is done, and it's a success ✅ .

@miss-islington miss-islington merged commit 9f101c2 into python:3.11 Jun 3, 2022
@miss-islington miss-islington deleted the backport-f32e6b4-3.11 branch June 3, 2022 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants