Skip to content

tests/cpydiff: Document 3-arg pow() rejecting bool on MPZ builds.#19155

Open
jseop-lim wants to merge 1 commit into
micropython:masterfrom
jseop-lim:cpydiff-pow3-bool
Open

tests/cpydiff: Document 3-arg pow() rejecting bool on MPZ builds.#19155
jseop-lim wants to merge 1 commit into
micropython:masterfrom
jseop-lim:cpydiff-pow3-bool

Conversation

@jseop-lim
Copy link
Copy Markdown
Contributor

@jseop-lim jseop-lim commented Apr 26, 2026

Summary

Documents the CPython divergence reported in #19144 as a cpydiff/ entry, instead of the code fix proposed in #19148.

On builds configured with MICROPY_LONGINT_IMPL_MPZ (the default for unix and most ports), the 3-argument pow() requires its operands to pass a strict integer type check, which excludes bool:

>>> pow(True, 1, 1)   # base
>>> pow(1, True, 1)   # exponent
>>> pow(1, 1, True)   # modulus
TypeError: pow() with 3 arguments requires integers   # MicroPython (MPZ)
0                                                     # CPython (all three)

Trade-offs and Alternatives

  • Alternative: code fix. py/objint_mpz: Accept bool in 3-arg pow(). #19148 took the implementation route. Per reviewer consensus, the size cost was not justified for the rarity of pow(x, y, bool) usage. Closing that PR in favour of this documentation.
  • Scope. Only the MPZ path is documented. The non-MPZ 3-arg path (py/modbuiltins.c) already accepts bool via mp_binary_op, so it is not a divergence and is intentionally not mentioned in the entry to keep the user-facing description tight. The cause field names MICROPY_LONGINT_IMPL_MPZ so readers on non-MPZ builds know the entry does not apply to them.
  • Categorisation. Filed under Types,int to match the existing types_int_* entries (to_bytes, bit_length, subclassconv); Core,Functions was considered but its existing entries cover function-call mechanics, not per-builtin input-domain quirks. Suggestions for a better category are welcome.

Generative AI

I used generative AI tools when creating this PR, but a human has checked the code and is responsible for the code and the description above.

Fix #19144.

Signed-off-by: Jeongseop Lim <jseoplim@gmail.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.46%. Comparing base (8a56be6) to head (4b95963).
⚠️ Report is 59 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #19155   +/-   ##
=======================================
  Coverage   98.46%   98.46%           
=======================================
  Files         176      176           
  Lines       22811    22811           
=======================================
  Hits        22460    22460           
  Misses        351      351           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dpgeorge dpgeorge added the tests Relates to tests/ directory in source label May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests Relates to tests/ directory in source

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3-arg pow() rejects bool in base, exponent, or modulus position

2 participants