Repository navigation
Validate star width and precision arguments in translations - #1402
Conversation
|
Thanks for covering the missing star arguments. There is one newly accepted incompatible pair when stars reuse the args = (3.5, "x")
"%d%s" % args # "3x"
"%*s" % args # TypeError: * wants int
python_format(None, Message("%d%s", "%*s")) # accepted at e06b245eThe base ( AI assistance was used to reproduce and review this; the commands were actually executed on CPython 3.12.14 using the base/head checker modules with Babel 2.17.0 dependencies. This was not a full repository test run. |
akx
left a comment
There was a problem hiding this comment.
LGTM. Starargs are pretty rare, but why not.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1402 +/- ##
==========================================
+ Coverage 93.37% 93.39% +0.02%
==========================================
Files 27 27
Lines 4922 4924 +2
==========================================
+ Hits 4596 4599 +3
+ Misses 326 325 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
python_formataccepts translations that add, remove, or move a*width/precision argument, even when formatting the translated string with the original arguments raisesTypeError. For example:Each dynamic width or precision consumes an integer argument before the converted value, as described in the Python formatting specification. Include those arguments in the existing positional compatibility checks using the integer conversion category. Numeric widths/precisions and escaped percent signs keep their existing behavior.
Add ten incompatible examples that first verify the source formats successfully and the translation fails at runtime; all ten fail the checker assertion before this fix. Seven compatible controls cover width/precision combinations, numeric conversion compatibility, negative widths, named placeholders, and escaped percent signs. A catalog-level test also checks an incompatible plural translation.
Validation on Windows, against
e2a1791, with imported CLDR 48.2:git diff --checkpassed.The complete runs used a workspace
--basetemppath without spaces. With the default temporary directory containing a space, an existingtest_compendium_with_commentassertion fails because PO comment wrapping splits the pathname. The same isolated failure was verified with the checker module restored from upstream; no test was deselected for the successful runs. One existing pytest parametrization deprecation warning remains. Other interpreter/platform combinations were not run.