Whole file

advice-animal/imperfect

The author described this change as Fix (and test) set_value on multiline strings. It counts as a record because the check below fails on the code as it stood at ba55d4836 and passes on 2c9d6c88d, with nothing else changed between the two runs.

Fix saved2020-03-08
Sharing licenceMIT · LICENSE
Change size+12 8

What the code was meant to do, written into the code itself as a save note

Fix (and test) set_value on multiline strings

The change

9292 return False
9393
9494 def set_value(self, key: str, value: str) -> None:
95- new_valueline = ValueLine(
96- text=value,
97- newline="\n",
98- whitespace_before_text="",
99- whitespace_after_text="",
100- )
95+ valuelines = [
96+ ValueLine(
97+ text=line,
98+ newline="\n",
99+ whitespace_before_text=" " if i > 0 else "",
100+ whitespace_after_text="",
101+ )
102+ for i, line in enumerate(value.splitlines(False))
103+ ]
104+
101105 for e in self.entries:
102106 if e.key.lower() == key:
103- e.value = [new_valueline]
107+ e.value = valuelines
104108 break
105109 else:
106110 self.entries.append(
107111 ConfigEntry(
108112 key=key,
109113 equals="=",
110- value=[new_valueline],
114+ value=valuelines,
111115 whitespace_before_equals=" ",
112116 whitespace_before_value=" ",
113117 )

The check that tells the two apart

failpass·imperfect/tests/editing.py::EditingTest::test_multiline_value

Check file imperfect/tests/editing.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before itba55d4836ee4fe4cdbb40952da5c643b81895775
Broken version dated2020-02-25
Moduleimperfect.types
Units changedConfigSection
Fingerprinte2ba8ac2ab587c36
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.