Artifacts Associated With Ticket 218947
Ticket change [4e5802db97] (rid 127214) by nobody on 2000-10-26 01:08:29:
- assignee initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
OriginalBugID: 2871 Bug Version: 8.2 SubmitDate: '1999-09-23' LastModified: '1999-10-20' Severity: SER Status: Released Submitter: techsupp ChangedBy: hobbs OS: Linux-SuSE OSVersion: 6.0 Machine: Other FixedDate: '1999-10-20' FixedInVersion: 8.2.2 ClosedDate: '2000-10-25' Name: Hans Banken ReproducibleScript: #!/usr/bin/tclsh set str "0123456789\x00\ abcdedfghi" puts "str: $str" puts "before scan - compare index 10 with \x00: [string compare [string index $str 10] \x00]" binary scan $str H* dump puts "access with string index: $dump\ncompare index 10 with \x00: [string compare [string index $str 10] \x00]" puts "access with string range: $dump\ncompare range 10,10 with \x00: [string compare [string range $str 10 10] \x00]" # Executing this script results in: # str: 0123456789 abcdedfghi # before scan - compare index 10 with : 0 # access with string index: 30313233343536373839002061626364656466676869 # compare index 10 with : -1 # access with string range: 30313233343536373839002061626364656466676869 # compare range 10,10 with : 0 ObservedBehavior: You might get wrong results when comparing the result of a string index operation This is tricky. What is happening is that the user is shimmering the object between a string and a bytearray. 'string' has an overloaded use, where it will access a bytearray by bytes, and strings as strings. In the first case, you get the unicode version of \x00. In the second, you get the true one-byte \x00 (just a null byte), which is not the same as the unicode one (which is two bytes). In the third case, STR_RANGE creates a bytearray obj, which will get converted OK. The problem appears to be that STR_INDEX for bytearrays wants to return a string type obj. -- 09/24/1999 hobbs Fixed 10/20/1999 (for 8.3b1) by making STR_INDEX for ByteArrays return a ByteArray object. -- 10/20/1999 hobbs - foundin initialized to: "obsolete: 8.2"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "nobody"
- subsystem initialized to: "69. Other"
- title initialized to:
string compare with result from string index does not work p
- type initialized to: "Bug"
Ticket change [ddc3d90a56] (rid 114729) by welch on 2000-10-26 08:32:14:
- closedate changed to: "2000-10-26T01:32:14"
- closer changed to: "welch"
- priority changed to: "2"
- resolution changed to: "Fixed"
- status changed to: "Closed"
Ticket change [16696660f0] (rid 124713) by dgp on 2001-04-19 03:33:36:
- closedate changed to: "2001-04-18T20:33:36"
- closer changed to: "dgp"
- subsystem changed to: "12. ByteArray Object"