Overview
| Artifact ID: | 0ad32f33471dacefab3eedeea025e3248e36067dd19a6db5a1d73f1eb5b3a258 |
|---|---|
| Ticket: | fcd3dadd79cf5681942c4ca9e6283afe8ec8af64
format honours LC_NUMERIC for %f/%g, producing numbers Tcl cannot parse |
| User & Date: | serhiy.storchaka on 2026-06-30 08:59:10 |
Changes
- cmimetype changed to: "text/x-markdown"
- comment changed to:
`format` converts floating-point values with the C library function `snprintf` (generic/tclStringObj.c, `Tcl_AppendFormatToObj`), which honours `LC_NUMERIC`. Under a comma-decimal locale, `format` emits a value that Tcl then refuses to parse, because its own number parser is locale-independent: % format %.1f 0.3 0,3 % expr {[format %.1f 0.3] + 0} expected floating-point number but got "0,3" Tcl resets `LC_NUMERIC` to `"C"` at init, so this only shows up under an embedder that sets a comma locale afterwards - for example a Python/tkinter program calling `locale.setlocale(locale.LC_NUMERIC, "de_DE.UTF-8")`. `Tcl_GetDoubleFromObj` and `Tcl_PrintDouble` are already locale-independent (`Tcl_PrintDouble` was fixed in <https://core.tcl-lang.org/tcl/tktview/3120139>); only `format` still leaks the locale. Making its floating-point conversions locale-independent (always `.`) would match that precedent and the new Tk helper `TkFormatDouble` (<https://core.tcl-lang.org/tk/tktview/348b482ff73e>). Concrete fallout: `ttk::spinbox` formats its value with `[format $fmt $val]`, so under a comma locale it writes `"0,3"` into its `-textvariable` and breaks (reported downstream as CPython issue <https://github.com/python/cpython/issues/84008>; the ttk-side remainder of the Tk fix above). - foundin changed to: "8.6, 8.7, 9.0, 9.1"
- status changed to: "Open"
- submitter changed to: "serhiy.storchaka"
- subsystem changed to: "16. Commands A-H"
- title changed to:
format honours LC_NUMERIC for %f/%g, producing numbers Tcl cannot parse
- type changed to: "Bug"