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.
Projectsimplistix/sybil
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
| 20 | 20 | col = position - self.text.rfind('\n', 0, position) | |
| 21 | 21 | return 'line {}, column {}'.format(line, col) | |
| 22 | 22 | ||
| 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 | + | ||
| 23 | 30 | def raise_overlap(self, *regions): | |
| 24 | 31 | reprs = [] | |
| 25 | 32 | 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)) | |
| 31 | 34 | raise ValueError('{} overlaps {}'.format(*reprs)) | |
| 32 | 35 | ||
| 33 | 36 | def add(self, region): | |
| 34 | 37 | 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 | + | )) | |
| 36 | 41 | 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 | + | )) | |
| 38 | 45 | entry = (region.start, region) | |
| 39 | 46 | index = bisect(self.regions, entry) | |
| 40 | 47 | if index > 0: |
The check that tells the two apart
fail→pass·tests/test_sybil.py::TestDocument::test_add_after_end
fail→pass·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.