diff options
author | oehhar <harald.oehlmann@elmicron.de> | 2022-09-11 13:45:04 (GMT) |
---|---|---|
committer | oehhar <harald.oehlmann@elmicron.de> | 2022-09-11 13:45:04 (GMT) |
commit | 32439d945eea3cc4754f2779090075c16256f18a (patch) | |
tree | 0565af014ca996276c452e4a7c5dbe1a189f8ab7 | |
parent | 1c7b977c449451a107b7b06b184689cfc8d066b4 (diff) | |
download | tcl-32439d945eea3cc4754f2779090075c16256f18a.zip tcl-32439d945eea3cc4754f2779090075c16256f18a.tar.gz tcl-32439d945eea3cc4754f2779090075c16256f18a.tar.bz2 |
Ticket [6978c01b65]: write not encodable character->report to script level Test io-75.5 now ok.
-rw-r--r-- | generic/tclIO.c | 13 | ||||
-rw-r--r-- | tests/io.test | 4 |
2 files changed, 15 insertions, 2 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c index 5317e30..732e103 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -4356,6 +4356,19 @@ Write( statePtr->outputEncodingFlags &= ~TCL_ENCODING_START; + /* + * See io-75.2, TCL bug 6978c01b65. + * Check, if an encoding error occured and should be reported to the + * script level. + * This happens, if a written character may not be represented by the + * current output encoding and strict encoding is active.hao_ + */ + + if (result == TCL_CONVERT_UNKNOWN) { + Tcl_SetErrno(EILSEQ); + return -1; + } + if ((result != TCL_OK) && (srcRead + dstWrote == 0)) { /* * We're reading from invalid/incomplete UTF-8. diff --git a/tests/io.test b/tests/io.test index 8b93317..9204208 100644 --- a/tests/io.test +++ b/tests/io.test @@ -8977,7 +8977,7 @@ test io-75.5 {unrepresentable character write passes and is replaced by ?} -setu set fn [makeFile {} io-75.5] set f [open $fn w+] fconfigure $f -encoding iso8859-1 -} -constraints knownBug -body { +} -body { puts -nonewline $f "A\u2022" } -body { puts -nonewline $f "A\u2022" @@ -8987,7 +8987,7 @@ test io-75.5 {unrepresentable character write passes and is replaced by ?} -setu } -cleanup { close $f removeFile io-75.5 -} -returnCodes error +} -returnCodes error -match glob -result {error writing "*": illegal byte sequence} # Incomplete sequence test. # This error may IMHO only be detected with the close. |