]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-91421: Use constant value check during runtime (GH-91422)
authorTobias Stoeckmann <stoeckmann@users.noreply.github.com>
Wed, 13 Apr 2022 03:01:02 +0000 (05:01 +0200)
committerGitHub <noreply@github.com>
Wed, 13 Apr 2022 03:01:02 +0000 (20:01 -0700)
commit0859368335d470b9ff33fc53ed9a85ec2654b278
tree51a39bc30ccbf02ba40f80ff6e0bced6ac47702c
parentac6c3de03c5bb06a9a463701fb297148f5a5746f
gh-91421: Use constant value check during runtime (GH-91422)

The left-hand side expression of the if-check can be converted to a
constant by the compiler, but the addition on the right-hand side is
performed during runtime.

Move the addition from the right-hand side to the left-hand side by
turning it into a subtraction there. Since the values are known to
be large enough to not turn negative, this is a safe operation.

Prevents a very unlikely integer overflow on 32 bit systems.

Fixes GH-91421.
Misc/NEWS.d/next/Core and Builtins/2022-04-10-22-57-27.gh-issue-91421.dHhv6U.rst [new file with mode: 0644]
Objects/unicodeobject.c