Skip to content
Tcl Source Code Artifact [03240dbc71]
Login

Artifact [03240dbc71]

Artifact 03240dbc71604cbab64ae80c693f0e7e3f59cbd61485734a70f298d6ce3389ec:

Ticket change [03240dbc71] - Ticket [8a13caa31dd8e3a5|8a13caa31d] <i>Setting of system encoding isn&#39;t applied to stdout on certain circumstances</i> status still Open with 3 other changes by apnadkarni on 2025-08-18 05:47:52.
D 2025-08-18T05:47:52.220
J icomment So,\sas\ssuspected,\sit\sis\snot\san\sencoding\sissue\sas\smuch\sas\sinitialization\sof\sstd\schannels.\sThe\stest\sfailure\sis\sa\sresult\sof\s`stdout`\sbeing\salready\sopen\sand\sconfigured\sfor\sutf-8\swhen\sthe\schild\sprocess\sin\sencoding-24.3\scalls\s`encoding\ssystem`.\sThus\sthe\soutput\sfrom\sthe\schild\sis\sencoded\sin\sutf-8,\sas\sthe\s`encoding\ssystem`\scommand\shas\sno\seffect\son\sexisting\schannels.\r\n\r\nThe\sdifference\sbetween\sthe\s`main`\sor\s`core-9-0-branch`\s(which\sdo\snot\ssee\sthe\stest\sfailure)\sand\sthe\s`apn-oo-lazy-init-sbmod`\sbranch\sis\sthat\stcltest\scalls\s`Tcl_OOInitStubs`\sas\spart\sof\sits\sinitialization.\sThat\sin\sturn\sdoes\sa\spackage\srequire\son\s`tcl::oo`.\s\r\n\r\nIn\sthe\scase\sof\sthe\s`apn-oo-lazy-init-sbmod`,\s`tcl::oo`\sis\sonly\sloaded\son\sdemand\s(via\s`oo::_init`)\sso\sthe\spackage\sloading\scode\sruns\swhen\s`Tcl_OOInitStubs`\sis\scalled\sand\sat\ssome\spoint\sloads\s`tclIndex`.\sThe\scall\sto\sopen\sthis\sfile\sleads\sto\sthe\sinitialization\sof\sthe\schannel\stable\swhich\sas\sa\sside\seffect\screates\sthe\sstandard\schannel\sincluding\sstdout.\sAs\sstdout\salready\sexists,\sits\sencoding\sis\snot\schanged\sby\s`encoding\ssystem`.\r\n\r\nIn\sthe\s`main`\sbranch,\soo\sis\salready\sloaded\sas\sa\spackage\sas\spart\sof\sTcl\sinitialization.\sThus\sthe\spackage\srequire\sdoes\snot\sgo\srummaging\sfor\stclIndex\sand\sstdout\stherefore\sremains\suninitialized\sand\sis\screated\sonly\safter\sthe\s`encoding\ssystem`\scommand\sand\stherefore\shas\sthe\sencoding\sspecified\sin\s`encoding\ssystem`.\r\n\r\nAs\san\sillustration,\sif\sthe\schild\sprocess\sscript\sin\sencoding-24.3\sis\smodified\sto\sadd\sa\s`package\srequire\splatform`\sat\sthe\stop,\sthe\ssame\sfailure\sis\sseen\sin\sthe\smain\sand\score-9-0-branch\sas\swell.\r\n\r\nFirst,\sI\sthink\sthis\sis\sa\sbug\sin\sencoding-24.3\sas\sit\spresumes\sstdout\sdoes\snot\sexist\swhen\sa\sscript\sis\srun\sand\sTcl\sdoes\snot\sguarantee\sthat\sis\sthe\scase.\sFixing\sthe\stest\sby\sadding\sa\sfconfigure\s(as\sSergey\soriginally\sreported)\smay\sbe\sone\soption\sbut\sI\sam\snot\ssure\sif\sthe\soriginal\sbug\sspecifically\swas\sintended\sto\sthe\ssystem\sencoding\sbeing\sattached\sto\sthe\sstandard\schannel.\r\n\r\nTo\sfix\sthe\sissue\sregardless,\sone\spossibility\sis\sto\schange\s`Tcl_OOInitStubs`\sto\sstatically\sload\sthe\spackage\sinstead\sof\sdoing\sa\spackage\srequire.\sI\sthink\sthe\spackage\srequire\swas\sonly\sneeded\sfor\s8.5\swhere\soo\swas\snot\sbuilt\sin.\sDoing\sa\sload,\sassuming\sit\sis\sfeasible,\swould\sbypass\sthe\spackage\simplementation\sand\sleave\schannels\sunchanged.\sHowever,\sI\sdon't\sthink\sthis\sis\sreally\smandated\sor\sabsolutely\snecessary\ssince\sscripts\sshould\snot\sreally\sassume\sthe\sstate\sof\sstd\schannels\sat\sstartup.\r\n\r\nAs\san\saside,\sI'm\ssurprised\sthe\stest\soutput\sprints\snuls\s(\\x00)\sas\sthe\sline\sread.\sThat\sis\sa\sseparate\sissue\sthat\smight\sneed\sto\sbe\slooked\sat\s(perhaps\sit's\sthe\stcltest\soutput\sascii-fication\sgetting\sit\swrong).
J login apnadkarni
J mimetype text/x-markdown
K 8a13caa31dd8e3a546b8d44c235bb98cd52bd774
U apnadkarni
Z adcda560b4ff9ada07a05b6d766cef05