Whole file
hgrecco/flexparser
The author described this change as “Fix set position and added tests”. It counts as a record because the check below fails on the code as it stood at 2048c4064 and passes on 54b243a9f, with nothing else changed between the two runs.
Projecthgrecco/flexparser
Fix saved2022-08-07
Sharing licenceBSD-2-Clause · LICENSE
Change size+5 −3
What the code was meant to do, written into the code itself as a save note
Fix set position and added tests
The change
| 443 | 443 | self._spliter.set_delimiters(delimiters) | |
| 444 | 444 | if self._cache: | |
| 445 | 445 | value = self.peek() | |
| 446 | - | self._spliter.set_position(value.start_line, value.start_col) | |
| 446 | + | # Elements are 1 based indexing, while splitter is 0 based. | |
| 447 | + | self._spliter.set_position(value.start_line - 1, value.start_col) | |
| 448 | + | self._cache.clear() | |
| 447 | 449 | ||
| 448 | 450 | def _get_next_strip(self) -> Statement: | |
| 449 | 451 | part = "" | |
| ⋯ | |||
| 623 | 625 | ||
| 624 | 626 | @property | |
| 625 | 627 | def format_position(self): | |
| 626 | - | if self.start_line == -1: | |
| 628 | + | if self.start_line is None: | |
| 627 | 629 | return "N/A" | |
| 628 | 630 | return "%d,%d-%d,%d" % self.get_position() | |
| 629 | 631 | ||
| ⋯ | |||
| 981 | 983 | ||
| 982 | 984 | def parse_bytes(self, b: bytes, bos: BOS = None) -> ParsedSource[RBT, CT]: | |
| 983 | 985 | if bos is None: | |
| 984 | - | bos = BOS(Hash.from_bytes(self._hasher, b)) | |
| 986 | + | bos = BOS(Hash.from_bytes(self._hasher, b)).set_simple_position(0, 0, 0) | |
| 985 | 987 | ||
| 986 | 988 | sic = self._statement_iterator_class( | |
| 987 | 989 | b.decode(self._encoding), self._delimiters, self._strip_spaces | |
The check that tells the two apart
fail→pass·flexparser/testsuite/test_iterators.py::test_statement_change_dlm
Check file flexparser/testsuite/test_iterators.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 it2048c406456ff00c011f177f2606e1ab0508b125
Broken version dated2022-08-07
Moduleflexparser.flexparser
Units changedBlock, Parser, StatementIterator
Fingerprint39d8adf26b49c9ee
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.