Repository navigation
math.log: handle large integer bases and error order - #9019
Conversation
Use the natural logarithm path for both operands, evaluating x first. Preserve large integer bases and raise ZeroDivisionError for base one while retaining noninteger conversion errors. Split the Python 3.14-compatible behavior from RustPython#8954 without its additional __index__ fallback or changes to log2 and log10. Assisted-by: OpenAI Codex:model identifier unavailable
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9d17669334
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| # assert math.log(1.1111) == math.log(Conversible()) | ||
|
|
||
| # A logarithm can fit in a float even when its integer base cannot. | ||
| assert math.isclose(math.log(2**4000, 2**2000), 2.0) |
There was a problem hiding this comment.
Remove the forbidden test additions
This block adds new assertions, helper classes, and test data to extra_tests/snippets/stdlib_math.py, but the repository's critical test-code rules forbid modifying test assertions, logic, or data and state that the only acceptable test-file changes are adding or removing expected-failure decorators. Remove this new test logic from the patch (or obtain a documented policy exception) before merging.
AGENTS.md reference: AGENTS.md:L273-L279
Useful? React with 👍 / 👎.
Summary
Split the Python 3.14-compatible
math.logbase handling from #8954.Use the existing natural-log conversion for both operands, evaluating
xbefore the base. This preserves the large-integer path for integer bases, avoids premature float overflow, and raisesZeroDivisionErrorwhen the base logarithm is zero.Keep
log2/log10and noninteger conversion behavior unchanged. In particular, an exception from__float__still propagates without retrying__index__.Extend the existing math snippet with large bases, base one, conversion ordering, integer subclasses, and conversion-error cases. No canonical standard-library assertions change.
Validation
d0dfcb54withOverflowErrorfor a large integer base.test_mathpass unchanged.--no-run, excluding WASM, venvlauncher, and C API; the separate C-API test target also compiles with--no-run.Local runtime validation is limited to the focused snippet, observations, and canonical tests above. Broad Rust test targets were compile-checked, not executed.
References: CPython 3.14 log conversion and evaluation order, float division.
AI assistance
OpenAI Codex assisted with auditing the split, implementation, regression coverage, and validation. The runtime does not expose an exact model identifier.