Skip to content
Tcl Source Code History Of Ticket 154ed7ce564a7b4c
Login

History Of Ticket 154ed7ce564a7b4c

Artifacts Associated With Ticket 154ed7ce564a7b4c

  1. Ticket change [4b2cae1fcf] (rid 207972) by pointsman on 2022-12-22 13:15:31:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/plain"
    4. comment initialized to:
      # Create the data
      package require Tcl 9
      set fd [open "data.txt" w+]
      fconfigure $fd -encoding binary
      # This is not valid UTF-8
      puts $fd AB\xc0\x40CD\nEFG
      close $fd
      
      # Now try to read it with [gets]
      set fd [open "data.txt"]
      fconfigure $fd -encoding utf-8 -strictencoding 1
      # That next line will hang indefinitely
      set data [gets $fd]
      puts "not reached"
      close $fd
      puts $data
      
      I'm not sure how this is supposed to work 
      but it surely should not work this way.
      
    5. foundin initialized to: "Tcl 9.0, trunk"
    6. is_private initialized to: "0"
    7. login: "pointsman"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "4ca203a8e925aecdd9419645f936bccf18cd6ea7"
    10. resolution initialized to: "None"
    11. severity initialized to: "Important"
    12. status initialized to: "Open"
    13. submitter initialized to: "pointsman"
    14. subsystem initialized to: "25. Channel System"
    15. title initialized to: "[gets] on -strictencoding 1 configured channel"
    16. type initialized to: "Bug"
  2. Ticket change [c6bdb92251] (rid 207974) by pointsman on 2022-12-22 13:27:51:

    1. login: "pointsman"
    2. mimetype: "text/plain"
    3. title changed to:
      Tcl 9: [gets] on -strictencoding 1 configured channel
      
  3. Ticket change [4e13af1770] (rid 207977) by jan.nijtmans on 2022-12-22 14:45:58:

    1. icomment: "Expected behavior: same as "read"."
    2. login: "jan.nijtmans"
    3. mimetype: "text/x-fossil-wiki"
  4. Ticket change [27b4573ac7] (rid 207989) by pointsman on 2022-12-25 00:14:28:

    1. icomment:
      You mean: Instead of the hang gets will return the line read so
      far in this situation (without raising error) and will raise
      error only on the next gets on the same channel?
      
      Please not. Please consider rasing error in the first place
      (and change "read" in the same way).
      
    2. login: "pointsman"
    3. mimetype: "text/plain"
  5. Ticket change [a2586325fc] (rid 208090) by pooryorick on 2023-01-02 21:10:21:

    1. icomment:
      Fixed in [003c9e1f2e53312b]:  [gets] returns an error when a decoding error occurs, and data successfully decoded up until the error is available in the "-result" entry of the return options.
      
    2. login: "pooryorick"
    3. mimetype: "text/x-fossil-wiki"
  6. Ticket change [393b9c6ea6] (rid 208224) by pooryorick on 2023-01-17 22:09:05:

    1. icomment:
      See issue [b8f575aa2398b0e4], where this issue is discussed for both [read] and [gets], and multiple alternative fixes are provided.
      
    2. login: "pooryorick"
    3. mimetype: "text/x-fossil-wiki"
  7. Ticket change [4687b617f5] (rid 208857) by pooryorick on 2023-02-18 01:16:24:

    1. icomment:
      The commit that caused this broken behaviour of [gets] was [a106c26dd5e8934f], "TIP #346: Error on Failed String Encodings".
      
    2. login: "pooryorick"
    3. mimetype: "text/x-fossil-wiki"
  8. Ticket change [357df60d3d] (rid 209110) by jan.nijtmans on 2023-02-23 15:22:41:

    1. icomment:
      From [Ashok's document](https://www.magicsplat.com/tcl9/tcl9unicode.html):
      
      _6.5.2 Channel read state after errors_
      
      Related to the above is the question of the channel state when an exception is raised on a read or gets due to invalid input bytes.
      
      My opinion is that when an exception is raised, the read position should not be changed from the value at the time the read or gets was invoked. This allows the application to then turn off the strict checking (if so desired) and read in the rest of the data. For example,
      
      <pre>
      % set fd [open x.txt r]
      file1de34c88158
      % fconfigure $fd -encoding utf-8 -strictencoding 1
      % gets $fd
      a
      % gets $fd
      error reading "file1de34c88158": illegal byte sequence
      % fconfigure $fd -encoding utf-8 -strictencoding 0
      % gets $fd
      bÀ
      % gets $fd
      c
      </pre>
      
      An alternate suggestion made in the mailing list was to move the read position to the location of the invalid byte and return the characters successfully decoded so far in the error options dictionary. My personal opinion is returning successfully read data in the error options is unnatural and non-idiomatic.
      
    2. login: "jan.nijtmans"
    3. mimetype: "text/x-markdown"
  9. Ticket change [a8f223b6de] (rid 210490) by jan.nijtmans on 2023-03-21 09:17:23:

    1. assignee changed to: "jan.nijtmans"
    2. closedate changed to: "2460024.8870761"
    3. closer changed to: "jan.nijtmans"
    4. icomment:
      Fixed [c02747a663bc158a|here], as discussed. In blocking mode, the exception is thrown immediately. In non-blocking mode, data read so far is returned.
      
      If an exception is thrown, there is no way to get back the read data so far, that will be handled in a separate TIP.
      
    5. login: "jan.nijtmans"
    6. mimetype: "text/x-fossil-wiki"
    7. resolution changed to: "Fixed"
    8. status changed to: "Closed"