diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2023-03-20 22:53:33 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2023-03-20 22:53:33 (GMT) |
commit | 4ea926a40b6c03000b32b4765503b75a3909dbc0 (patch) | |
tree | a27724dc78893276973e3fbf759a35fb58eca8d9 /tests/io.test | |
parent | 8133df3b6d12fd4fa798c7917979517d34f97996 (diff) | |
download | tcl-4ea926a40b6c03000b32b4765503b75a3909dbc0.zip tcl-4ea926a40b6c03000b32b4765503b75a3909dbc0.tar.gz tcl-4ea926a40b6c03000b32b4765503b75a3909dbc0.tar.bz2 |
Proposed fix for [154ed7ce56]: Tcl 9: [gets] on -strictencoding 1 configured channel.
Extracted from TIP #657 branch (better keeping bug-fix separate from enhancements)
Diffstat (limited to 'tests/io.test')
-rw-r--r-- | tests/io.test | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/tests/io.test b/tests/io.test index c3c0cdd..cf90936 100644 --- a/tests/io.test +++ b/tests/io.test @@ -9155,6 +9155,22 @@ test io-75.5 {invalid utf-8 encoding read is ignored (-profile tcl8)} -setup { removeFile io-75.5 } -result 4181 +test io-75.6 {invalid utf-8 encoding gets is not ignored (-profile strict)} -setup { + set fn [makeFile {} io-75.6] + set f [open $fn w+] + fconfigure $f -encoding binary + # \x81 is invalid in utf-8 + puts -nonewline $f A\x81 + flush $f + seek $f 0 + fconfigure $f -encoding utf-8 -buffering none -eofchar "" -translation lf -profile strict +} -body { + gets $f +} -cleanup { + close $f + removeFile io-75.6 +} -match glob -returnCodes 1 -result {error reading "*": illegal byte sequence} + test io-75.8 {invalid utf-8 encoding eof handling (-profile strict)} -setup { set fn [makeFile {} io-75.8] set f [open $fn w+] @@ -9243,10 +9259,10 @@ test io-75.12 {invalid utf-8 encoding read is ignored} -setup { fconfigure $f -encoding utf-8 -buffering none -eofchar "" -translation lf } -body { set d [read $f] - close $f binary scan $d H* hd set hd } -cleanup { + close $f removeFile io-75.12 } -result 4181 test io-75.13 {invalid utf-8 encoding read is not ignored (-profile strict)} -setup { @@ -9262,9 +9278,9 @@ test io-75.13 {invalid utf-8 encoding read is not ignored (-profile strict)} -se set d [read $f] binary scan $d H* hd lappend hd [catch {read $f} msg] - close $f lappend hd $msg } -cleanup { + close $f removeFile io-75.13 } -match glob -result {41 1 {error reading "*": illegal byte sequence}} |