Whole file

uiri/toml

The author described this change as Fix #148 and add test for it. It counts as a record because the check below fails on the code as it stood at a2a7b92d1 and passes on b1f30f473, with nothing else changed between the two runs.

Projectuiri/toml
Fix saved2018-02-01
Sharing licenceMIT · LICENSE
Change size+17 2

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

Fix #148 and add test for it

The change

167167 if singlequote:
168168 v = v.replace("\\'", "'")
169169 v = v.replace('"', '\\"')
170- v = v.replace("\\x", "\\u00")
171- return unicode('"' + v + '"')
170+ v = v.split("\\x")
171+ while len(v) > 1:
172+ i = -1
173+ if not v[0]:
174+ v = v[1:]
175+ v[0] = v[0].replace("\\\\", "\\")
176+ # No, I don't know why != works and == breaks
177+ joinx = v[0][i] != "\\"
178+ while v[0][:i] and v[0][i] == "\\":
179+ joinx = not joinx
180+ i -= 1
181+ if joinx:
182+ joiner = "x"
183+ else:
184+ joiner = "u00"
185+ v = [v[0] + joiner + v[1]] + v[2:]
186+ return unicode('"' + v[0] + '"')
172187
173188
174189 def _dump_list(v):

The check that tells the two apart

failpass·tests/test_api.py::test_bug_148

Check file tests/test_api.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 ita2a7b92d1da95144648c295abef6380b5f489618
Broken version dated2018-01-28
Moduletoml.encoder
Units changed_dump_str
Fingerprintf9abc1716103f289
Checked2026-08-18 by goldset/0.1

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

Other bugs found in uiri/toml