One function

Document in simplistix/sybil

The author described this change as Better feedback when parsing goes wrong.. It counts as a record because the checks below fail on the code as it stood at e66ae11bd and pass on a671b3c58, with nothing else changed between the two runs.

Fix saved2018-01-25
Sharing licenceMIT · LICENSE.txt
Change size+14 7

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

This is Sybil's representation of a documentation source file. It will be instantiated by Sybil and provided to each parser in turn.

The change

2020 col = position - self.text.rfind('\n', 0, position)
2121 return 'line {}, column {}'.format(line, col)
2222
23+ def region_details(self, region):
24+ return '{!r} from {} to {}'.format(
25+ region,
26+ self.line_column(region.start),
27+ self.line_column(region.end)
28+ )
29+
2330 def raise_overlap(self, *regions):
2431 reprs = []
2532 for region in regions:
26- reprs.append('{!r} from {} to {}'.format(
27- region,
28- self.line_column(region.start),
29- self.line_column(region.end)
30- ))
33+ reprs.append(self.region_details(region))
3134 raise ValueError('{} overlaps {}'.format(*reprs))
3235
3336 def add(self, region):
3437 if region.start < 0:
35- raise ValueError('{!r} is before start of document'.format(region))
38+ raise ValueError('{} is before start of document'.format(
39+ self.region_details(region)
40+ ))
3641 if region.end > self.end:
37- raise ValueError('{!r} goes beyond end of document'.format(region))
42+ raise ValueError('{} goes beyond end of document'.format(
43+ self.region_details(region)
44+ ))
3845 entry = (region.start, region)
3946 index = bisect(self.regions, entry)
4047 if index > 0:

The check that tells the two apart

failpass·tests/test_sybil.py::TestDocument::test_add_after_end
failpass·tests/test_sybil.py::TestDocument::test_add_before_start

Check file tests/test_sybil.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 ite66ae11bd033d24af714aea5d79d9a6e4b3bf7ab
Broken version dated2017-11-30
Modulesybil.document
Units changedDocument
Fingerprintc5f1900aa5af02cc
Checked2026-08-18 by goldset/0.1

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