8000 bpo-24076: Fix reference in sum() introduced by GH-28469 by pablogsal · Pull Request #28493 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-24076: Fix reference in sum() introduced by GH-28469 #28493

8000 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 2 commits into from
Sep 21, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
8000
Diff view
Next Next commit
bpo-24076: Fix reference in sum() introduced by GH-28469
  • Loading branch information
pablogsal committed Sep 21, 2021
commit bd121ecf868683a3d284ff216e7c84dea5e2be9a
2 changes: 1 addition & 1 deletion Python/bltinmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -2484,7 +2484,7 @@ builtin_sum_impl(PyObject *module, PyObject *iterable, PyObject *start)
< 8000 /td> /* Single digits are common, fast, and cannot overflow on unpacking. */
switch (Py_SIZE(item)) {
case -1: b = -(sdigit) ((PyLongObject*)item)->ob_digit[0]; break;
case 0: continue;
case 0: Py_DECREF(item); continue;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking that the "continue" warrants a comment. Inside a switch-case, a break ends a case but a continue means to go to the top of the loop. The side-by-side use of break and continue is a bit confusing (I did a double take when I first saw it); hence, my suggestion to add a comment.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I actually didn't add it before to keep the PR contained. But makes sense. I have pushed a comment in the new commit

case 1: b = ((PyLongObject*)item)->ob_digit[0]; break;
default: b = PyLong_AsLongAndOverflow(item, &overflow); break;
}
Expand Down
0