Skip to content
Tcl Source Code View Ticket
Login

View Ticket

Error-handling when stderr is in "strict" profile

Closed / Fixed0df5906dd7e4beb33712ed51437ebb4369c3c101Created 3 years agoUpdated 42 days ago
Descriptionplain2023-09-28 15:18:56
Example:
<pre>
$ tclsh8.7
% fconfigure stderr -profile strict
% set env(abc\ud800)
can't read "env(abc
%
</pre>

The expected output would be something like:
<pre>
% set env(abc\ud800)
can't read "env(abc\ud800)": no such variable
</pre>

But, what happens is that \ud800 is an illegal character in the strict profile, so the stderr output is truncated there.

At least, the stderr output should indicate what's going on here
Referenced by3
jan.nijtmanswiki2023-09-28 15:26:36

Proposed fix [here]

apnadkarnimarkdown2023-09-28 16:25:13

For troubleshooting purposes I think it is important to get as much of the text written out as possible. If all one sees is encoding error in stderr, it is completely unhelpful.

I would propose that stderr use the REPLACE (my preference) or (TCL8) profile even in strict mode.

Of course this can be configured by applications at startup but since it is the preferred behavior in my estimation, it should be made the default (for stderr).

jan.nijtmanswiki2023-09-28 18:16:55

Thanks, Ashok, I was thinking in about the same way. So TIP #657 needs to be modified, adding the "stderr" channel as an exception: "stderr" will be opened "-profile replace" by default (my preference too).

Still, if someone sets "stderr" to strict profile, the channel should do as expected ..... adding *encoding error in stderr* is - at the very least - an improvement over how it is now.

The handling in ::tcl::Bgerror has the same problem.

jan.nijtmans Pending ticket [0df5906dd7]. [History diff]2023-09-28 18:20:42
serhiy.storchakawiki2026-10-15 11:39:51

Fixed by [166b00eb0c]; stderr now also defaults to -profile replace as in TIP 657. Released in 9.0.0.

serhiy.storchaka Ticket [0df5906dd7]: 3 changes [History diff]2026-10-22 17:19:26
Log in (anonymous is fine) to add a comment.