Repository navigation
Decode decimal fields independently of the active context - #488
JackyHsu-X wants to merge 2 commits into
Conversation
Signed-off-by: JackyHsu-X <xv1070733106@gmail.com>
|
@LuisFigueroaG can you review this? |
Signed-off-by: JackyHsu-X <xv1070733106@gmail.com>
|
Updated the branch for main The merged checkout passes all unit and simulated-protocol integration tests: 400 passed, 27 broker-dependent skips. Latest upstream still fails 8 of the 10 Decimal-context regression cases; the two zero-value controls pass. The configured trailing-whitespace hook was run directly from its existing v6.0.0 cached environment and passed, along with |
AMQP decimal fields are decoded with division, so the active decimal context can round valid message headers or raise an arithmetic exception. For example, decoding coefficient
2147483647with scale2at precision3returnsDecimal('2.15E+7')instead ofDecimal('21474836.47'); enabling theInexacttrap makes decoding fail.Construct the Decimal directly from its sign, digits and negative wire scale. This avoids context-dependent arithmetic and keeps the wire value exact without changing the caller's flags or settings.
The regression test decodes a raw field table containing both a nested table and an array, followed by an integer field. It covers signed 32-bit boundaries, scales 0 and 255, zero, low precision, restricted exponent bounds and enabled/disabled Inexact traps, and checks the final byte offset and unchanged context flags. A changelog entry is included.
Validation on Windows / Python 3.13.15:
python -m pytest t/unit t/integration -q— 400 passed, 27 skipped (RabbitMQ-dependent tests).git diff --checkpassed.No live RabbitMQ or full Python-version matrix was run. This addresses decoding only; #487 addresses positive exponents on the encoding side.
Developed with assistance from OpenAI Codex.
Upstream integration (2026-11-02)
Updated the branch for main
9d4a51a(5.4.2). The only conflict was inChangelog: the pending Decimal fix remains inUnreleased, above the complete upstream 5.4.2 release notes. Upstream version changes are retained; the decoder and regression-test blobs are unchanged. Relative to updated main, the contribution remains three files, 39 insertions / 2 deletions.The merged checkout passes all unit and simulated-protocol integration tests: 400 passed, 27 broker-dependent skips. Latest upstream still fails 8 of the 10 Decimal-context regression cases; the two zero-value controls pass. The configured trailing-whitespace hook was run directly from its existing v6.0.0 cached environment and passed, along with
git diff --check. No dependency was installed or upgraded. Real RabbitMQ, other operating systems and the full Python matrix were not run. Codex prepared and validated this integration.