Skip to content

Signature of slice is documented incorrectly #107755

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

Closed
wimglenn opened this issue Aug 8, 2023 · 0 comments
Closed

Signature of slice is documented incorrectly #107755

wimglenn opened this issue Aug 8, 2023 · 0 comments
Assignees
Labels
docs Documentation in the Doc dir

Comments

@wimglenn
Copy link
Contributor

wimglenn commented Aug 8, 2023

Documentation

https://docs.python.org/3/library/functions.html#slice currently shows:

class slice(start, stop, step=1)

This was changed from slice(start, stop[, step]) in #96579. That default for step is incorrect. It's correct in a range, but in a slice it actually defaults to None:

>>> slice(1,2).step is None
True

Most code handle step=1 and step=None the same way when receiving a slice, but user defined types implementing __getitem__/__setitem__/__delitem__ aren't obliged to, and the correct default should be documented.

Linked PRs

@wimglenn wimglenn added the docs Documentation in the Doc dir label Aug 8, 2023
wimglenn added a commit to wimglenn/cpython that referenced this issue Aug 8, 2023
@rhettinger rhettinger self-assigned this Aug 13, 2023
wimglenn added a commit to wimglenn/cpython that referenced this issue Aug 15, 2023
encukou pushed a commit that referenced this issue Sep 5, 2023
Document the correct default value of slice step.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Sep 5, 2023
…thonGH-107756)

Document the correct default value of slice step.
(cherry picked from commit 9bf350b)

Co-authored-by: wim glenn <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Sep 5, 2023
…thonGH-107756)

Document the correct default value of slice step.
(cherry picked from commit 9bf350b)

Co-authored-by: wim glenn <[email protected]>
vstinner pushed a commit that referenced this issue Sep 7, 2023
…H-107756) (#108956)

gh-107755: Document the correct default value of slice step (GH-107756)

Document the correct default value of slice step.
(cherry picked from commit 9bf350b)

Co-authored-by: wim glenn <[email protected]>
Yhg1s pushed a commit that referenced this issue Sep 8, 2023
…H-107756) (#108955)

gh-107755: Document the correct default value of slice step (GH-107756)

Document the correct default value of slice step.
(cherry picked from commit 9bf350b)

Co-authored-by: wim glenn <[email protected]>
@wimglenn wimglenn closed this as completed Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir
Projects
None yet
Development

No branches or pull requests

2 participants