Ticket UUID: | 7238d28e2550ae6f0301fe3d241ab08ac17ce0b0 | |||
Title: | Handling of empty values in 'dict print' of module dicttool | |||
Type: | Patch | Version: | 1.18 | |
Submitter: | anonymous | Created on: | 2018-04-22 12:10:25 | |
Subsystem: | (unused) | Assigned To: | hypnotoad | |
Priority: | 3 Low | Severity: | Minor | |
Status: | Closed | Last Modified: | 2020-02-18 19:44:49 | |
Resolution: | By Design | Closed By: | hypnotoad | |
Closed on: | 2020-02-18 19:44:49 | |||
Description: |
% package req dicttool 1.1 % set d {a 55 b {} c " "} a 55 b {} c " " % dict print $d a 55 b { } c { } # it should be: a 55 b {} c { }The following patch corrects both problems: ------------------------ --- dicttool.tcl 2018-02-02 05:38:38.000000000 +0200 +++ dicttool1.tcl 2018-04-22 14:56:18.783045692 +0300 @@ -71,7 +71,7 @@ } ::incr indent -2 ::append buffer \n [::string repeat " " $indent] "\}" - } elseif {[string index $field end] eq ":" || ![is_dict $value]} { + } elseif {[string index $field end] eq ":" || ![is_dict $value] || ![::llength $value]} { ::append buffer [::list $value] } else { ::incr indent 2------------------------ dzach | |||
User Comments: |
hypnotoad added on 2020-02-18 19:44:24:
dzach is correct, dict print really can't tell an empty string from a subtree, and the only way to prevent unsightly printouts or errors is to provide hints through notation. As they say in the museum industry... defects inherent in the material aku added on 2018-05-17 19:55:27: Sean, can you have a look at this ? anonymous (claiming to be dzach) added on 2018-04-24 07:25:11: Changed severity to 'minor' anonymous (claiming to be dzach) added on 2018-04-22 21:41:28: I think I missed the point that the value is a leaf, therefore a key ending in a ':' would direct 'dict print' to print the value as is. Therefore this is not a bug. dzach |