◐ Shell
reader mode source ↗
Skip to content

bpo-29816: Shift operation now has less opportunity to raise OverflowError.#680

Merged
serhiy-storchaka merged 7 commits into
python:masterfrom
serhiy-storchaka:long-shift-overflow
Mar 30, 2017
Merged

bpo-29816: Shift operation now has less opportunity to raise OverflowError.#680
serhiy-storchaka merged 7 commits into
python:masterfrom
serhiy-storchaka:long-shift-overflow

Conversation

@serhiy-storchaka

Copy link
Copy Markdown
Member

ValueError always is raised rather than OverflowError for negative counts.
Shifting zero with non-negative count always returns zero.

…Error.

ValueError always is raised rather than OverflowError for negative counts.
Shifting zero with non-negative count always returns zero.
@mention-bot

Copy link
Copy Markdown

@serhiy-storchaka, thanks for your PR! By analyzing the history of the files in this pull request, we identified @mdickinson, @tim-one and @brettcannon to be potential reviewers.

@mdickinson mdickinson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hide comment

Looks okay to me, but if feels a bit convoluted and hard to read / hard to verify. Why not use PyLong arithmetic in the overflow case, for example using divrem1 to extract the number of words / number of bits to shift?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants