Commit 476cfa4
Fix GCD and test_int for 60-bit PyLong digits
Two fixes for 60-bit digit support:
1. Fix _PyLong_GCD() to return non-negative results for 60-bit digits
- The 60-bit path in the "simple" case was skipping long_abs() calls
- This caused gcd(-1, 0) to return -1 instead of 1
- Added long_abs() calls for both inputs before the GCD algorithm
- Fixes test_math::testGcd and all test_pow failures (3,075 cases)
2. Adjust test_pylong_int_divmod_crash for larger digit sizes
- The test uses k=10,000 to ensure _pylong.int_divmod() is called
- With 60-bit digits, the threshold is higher (need more bits/digits)
- Scale k based on bits_per_digit: k = 10,000 * (bits_per_digit // 30)
- For 60-bit: k=20,000, for 30-bit: k=10,000, for 15-bit: k=5,000
All previously failing tests now pass:
- test_decimal: OK
- test_fractions: OK
- test_int: OK (was 1 failure)
- test_math: OK (was 7 failures)
- test_numeric_tower: OK
- test_pow: OK (was 3,075 failures)
- test_statistics: OK
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>1 parent 671323d commit 476cfa4
2 files changed
+19
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
784 | 784 | | |
785 | 785 | | |
786 | 786 | | |
787 | | - | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
788 | 790 | | |
789 | 791 | | |
790 | 792 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5899 | 5899 | | |
5900 | 5900 | | |
5901 | 5901 | | |
| 5902 | + | |
| 5903 | + | |
| 5904 | + | |
| 5905 | + | |
| 5906 | + | |
| 5907 | + | |
| 5908 | + | |
| 5909 | + | |
| 5910 | + | |
| 5911 | + | |
| 5912 | + | |
| 5913 | + | |
| 5914 | + | |
| 5915 | + | |
| 5916 | + | |
| 5917 | + | |
5902 | 5918 | | |
5903 | 5919 | | |
5904 | 5920 | | |
| |||
0 commit comments