Skip to content
Tcl Source Code Artifact [0ad32f3347]
Login

Artifact [0ad32f3347]

Artifact 0ad32f33471dacefab3eedeea025e3248e36067dd19a6db5a1d73f1eb5b3a258:

Ticket change [0ad32f3347] - New ticket [fcd3dadd79cf5681|fcd3dadd79] <i>format honours LC_NUMERIC for %f/%g, producing numbers Tcl cannot parse</i>. by serhiy.storchaka on 2026-06-30 08:59:10.
D 2026-06-30T08:59:10.699
J cmimetype text/x-markdown
J comment `format`\sconverts\sfloating-point\svalues\swith\sthe\sC\slibrary\sfunction\s`snprintf`\n(generic/tclStringObj.c,\s`Tcl_AppendFormatToObj`),\swhich\shonours\s`LC_NUMERIC`.\nUnder\sa\scomma-decimal\slocale,\s`format`\semits\sa\svalue\sthat\sTcl\sthen\srefuses\sto\nparse,\sbecause\sits\sown\snumber\sparser\sis\slocale-independent:\n\n\s\s\s\s%\sformat\s%.1f\s0.3\n\s\s\s\s0,3\n\s\s\s\s%\sexpr\s{[format\s%.1f\s0.3]\s+\s0}\n\s\s\s\sexpected\sfloating-point\snumber\sbut\sgot\s"0,3"\n\nTcl\sresets\s`LC_NUMERIC`\sto\s`"C"`\sat\sinit,\sso\sthis\sonly\sshows\sup\sunder\san\sembedder\nthat\ssets\sa\scomma\slocale\safterwards\s-\sfor\sexample\sa\sPython/tkinter\sprogram\ncalling\s`locale.setlocale(locale.LC_NUMERIC,\s"de_DE.UTF-8")`.\n\n`Tcl_GetDoubleFromObj`\sand\s`Tcl_PrintDouble`\sare\salready\slocale-independent\n(`Tcl_PrintDouble`\swas\sfixed\sin\s<https://core.tcl-lang.org/tcl/tktview/3120139>);\nonly\s`format`\sstill\sleaks\sthe\slocale.\s\sMaking\sits\sfloating-point\sconversions\nlocale-independent\s(always\s`.`)\swould\smatch\sthat\sprecedent\sand\sthe\snew\sTk\shelper\n`TkFormatDouble`\s(<https://core.tcl-lang.org/tk/tktview/348b482ff73e>).\n\nConcrete\sfallout:\s`ttk::spinbox`\sformats\sits\svalue\swith\s`[format\s$fmt\s$val]`,\sso\nunder\sa\scomma\slocale\sit\swrites\s`"0,3"`\sinto\sits\s`-textvariable`\sand\sbreaks\n(reported\sdownstream\sas\sCPython\sissue\n<https://github.com/python/cpython/issues/84008>;\sthe\sttk-side\sremainder\sof\sthe\nTk\sfix\sabove).
J foundin 8.6,\s8.7,\s9.0,\s9.1
J status Open
J submitter serhiy.storchaka
J subsystem 16.\sCommands\sA-H
J title format\shonours\sLC_NUMERIC\sfor\s%f/%g,\sproducing\snumbers\sTcl\scannot\sparse
J type Bug
K fcd3dadd79cf5681942c4ca9e6283afe8ec8af64
U serhiy.storchaka
Z c61e9d516787ff68fc5f1c48b98ce171