summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorapnadkarni <apnmbx-wits@yahoo.com>2023-12-05 16:57:32 (GMT)
committerapnadkarni <apnmbx-wits@yahoo.com>2023-12-05 16:57:32 (GMT)
commit4f1e1c42b0e26190057bb915acf701907f82ff63 (patch)
tree3841ffa77e126d312d090b3dd66583b2548a5f35
parent85e3751c642a33bb65b2fa23fb103961fa2436c3 (diff)
downloadtcl-4f1e1c42b0e26190057bb915acf701907f82ff63.zip
tcl-4f1e1c42b0e26190057bb915acf701907f82ff63.tar.gz
tcl-4f1e1c42b0e26190057bb915acf701907f82ff63.tar.bz2
Also ensure no encoding exceptions raised when reading pipe stderr
-rw-r--r--tests/exec.test15
-rw-r--r--unix/tclUnixPipe.c2
-rw-r--r--win/tclWinPipe.c4
3 files changed, 19 insertions, 2 deletions
diff --git a/tests/exec.test b/tests/exec.test
index 7f40a38..4f7a1a8 100644
--- a/tests/exec.test
+++ b/tests/exec.test
@@ -714,7 +714,7 @@ test exec-20.1 {exec .CMD file} -constraints {win} -body {
} -result "\"Testing exec-20.1\""
# Test with encoding mismatches (Bug 0f1ddc0df7fb7)
-test exec-21.1 {exec encoding mismatch} -setup {
+test exec-21.1 {exec encoding mismatch on stdout} -setup {
set path(script) [makeFile {
fconfigure stdout -translation binary
puts a\xe9b
@@ -727,6 +727,19 @@ test exec-21.1 {exec encoding mismatch} -setup {
} -body {
exec [info nameofexecutable] $path(script)
} -result a\uFFFDb
+test exec-21.2 {exec encoding mismatch on stderr} -setup {
+ set path(script) [makeFile {
+ fconfigure stderr -translation binary
+ puts stderr a\xe9b
+ } script]
+ set enc [encoding system]
+ encoding system utf-8
+} -cleanup {
+ removeFile $path(script)
+ encoding system $enc
+} -body {
+ list [catch {exec [info nameofexecutable] $path(script)} r] $r
+} -result [list 1 a\uFFFDb]
# ----------------------------------------------------------------------
diff --git a/unix/tclUnixPipe.c b/unix/tclUnixPipe.c
index a889f1d..f1e3fb8 100644
--- a/unix/tclUnixPipe.c
+++ b/unix/tclUnixPipe.c
@@ -1102,6 +1102,8 @@ PipeClose2Proc(
errChan = Tcl_MakeFileChannel(
INT2PTR(GetFd(pipePtr->errorFile)),
TCL_READABLE);
+ /* Error channels should raise encoding errors */
+ Tcl_SetChannelOption(NULL, errChan, "-profile", "replace");
} else {
errChan = NULL;
}
diff --git a/win/tclWinPipe.c b/win/tclWinPipe.c
index 600c146..5a18ee3 100644
--- a/win/tclWinPipe.c
+++ b/win/tclWinPipe.c
@@ -2123,7 +2123,9 @@ PipeClose2Proc(
errChan = Tcl_MakeFileChannel((void *) filePtr->handle,
TCL_READABLE);
Tcl_Free(filePtr);
- } else {
+ Tcl_SetChannelOption(NULL, errChan, "-profile", "replace");
+ }
+ else {
errChan = NULL;
}