Skip to content

Preserve floating-point results of negative integer powers - #640

Open
fhgffy wants to merge 1 commit into
python-poetry:masterfrom
fhgffy:fix/integer-negative-powers-20261009
Open

fhgffy wants to merge 1 commit into
python-poetry:masterfrom
fhgffy:fix/integer-negative-powers-20261009

Conversation

@fhgffy

@fhgffy fhgffy commented Oct 9, 2026 •

Copy link
Copy Markdown

Summary

Negative powers of integer items currently disagree with their serialized value: item(2) ** -1 compares equal to 0, but renders as 0.5. Fractional exponents also raise instead of allowing Python's reflected float operation.

Keep floating-point power results as Float items and pass NotImplemented back to Python for reflected dispatch. Positive and modular integer powers retain their existing result type.

Tests: 12 new cases pass (7 fail on the original implementation); the complete suite passes with 1109 tests on Python 3.12. Ruff and formatting checks pass, and both wheel and sdist build. Mypy reports the same five pre-existing errors on the original and patched source.

The downstream Poetry integration fails one extraction assertion on Python 3.12.15. A controlled replay with the official tarfile modules reproduces the difference without importing tomlkit: 3.12.15 normalizes the path and writes safely inside the destination, while the unchanged Poetry test expects OutsideDestinationError. The test expectation is addressed in python-poetry/poetry#11133.

Agent Drafting Metadata

  • Agent: Codex
  • Model: GPT-6
  • Notes: Assisted with investigation, the patch and regression tests.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant