fix(code-runtime-python): make the float encoder context-independent; correct the binding-reply README entry

The review's critical: Decimal(repr(value)).normalize() read the process-global
decimal context, so a legitimate program setting getcontext().prec = 2 silently
rounded the completion value's digits and traps[Inexact] = True made the encode
raise, misclassifying a successful run as an exception. A fixed module-level
Context(prec=28) makes the spelling decision context-independent; a regression
case mutates both context knobs and asserts the float round-trips exactly.

The binding-reply README entry now states the fact (no seam-level cap;
maxValueBytes meters only the done frame; a wide reply is rebuilt and encoded
whole, bounded by process memory), matching the earlier reviewer wording.
This commit is contained in:
Chinesezjc
2026-08-31 15:02:38 +08:00
committed by Tianyi Cui
parent 666ff2855e
commit 35de0682c7
5 changed files with 35 additions and 7 deletions
@@ -2,5 +2,5 @@
# side as of the last confirmed-consistent state. Both languages carry equal authority;
# after editing either side, bring the other along and re-record with:
# pnpm run verify-translation-pairing --write packages/code-runtime/code-runtime-python/README.md
README.md: 557ff7f58b70fcbc5cd9d7901c0c6b66d123c0eb
README.zh.md: d98fdcc52a05541c66e050445ebc04264686451b
README.md: c6ab48b5ccd4e386f9ad416dee64b090500594f6
README.zh.md: 637de914212be9b7e6a3b63e443d7252c092acf2