synchronous [read] with -strictencoding does not produce an error on invalid input
test io-12.9 {ReadChars: multibyte chars split} -body {
set f [open $path(test1) w]
fconfigure $f -translation binary
puts -nonewline $f [string repeat a 9]\xC2
close $f
set f [open $path(test1)]
fconfigure $f -strictencoding 1 -encoding utf-8 -buffersize 10
set in [read $f]
close $f
scan [string index $in end] %c
} -cleanup {
catch {close $f}
} -result 194
This is incorrect. An error should be returned.
If a second [read] is added, it returns an error:
test io-12.9 {ReadChars: multibyte chars split} -body {
set f [open $path(test1) w]
fconfigure $f -translation binary
puts -nonewline $f [string repeat a 9]\xC2
close $f
set f [open $path(test1)]
fconfigure $f -strictencoding 1 -encoding utf-8 -buffersize 10
set in [read $f]
read $f
close $f
scan [string index $in end] %c
} -cleanup {
catch {close $f}
} -result 194
This is also incorrect, because [read $chan] is defined to read all characters up until the end of the channel, implying that all data on the channel has been correctly read.
The first [read] should return an error.
90a548d283Ticket [6978c01b65] Channel encoding difference 8.6 <-> 9.0 status still Closed with 4 other changes ticket2023-03-24 22:00:2765e92802c3Merge trunk 78beedf7e2: Fix [1bedc53c8c]: synchronous [read] with -strictencoding does not produce an error on invalid input. check-in2023-03-24 13:18:5118437bdc82Fix [1bedc53c8c]: synchronous [read] with -strictencoding does not produce an error on invalid input check-in2023-03-21 16:28:57a7bce7dbbaProposed fix for [1bedc53c8c]: synchronous [read] with -strictencoding does not produce an error on invalid input check-in2023-03-20 23:17:11e2a1886fc3Ticket [b8f575aa23] Tcl 9: eof errorneously flagged with not reported encoding read error status still Open with 3 other changes ticket2022-12-29 23:38:34
Report. [b8f575aa2398b0e4] was closed as a duplicate of this report. Branch py-b8f575aa23 is dedicated to this issue.
Closed as duplicate of [b8f575aa2398b0e4]."Tcl 9: eof erroneously flagged with not reported encoding read error"
Fixed [here]