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.

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

443443 self._spliter.set_delimiters(delimiters)
444444 if self._cache:
445445 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()
447449
448450 def _get_next_strip(self) -> Statement:
449451 part = ""
623625
624626 @property
625627 def format_position(self):
626- if self.start_line == -1:
628+ if self.start_line is None:
627629 return "N/A"
628630 return "%d,%d-%d,%d" % self.get_position()
629631
981983
982984 def parse_bytes(self, b: bytes, bos: BOS = None) -> ParsedSource[RBT, CT]:
983985 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)
985987
986988 sic = self._statement_iterator_class(
987989 b.decode(self._encoding), self._delimiters, self._strip_spaces

The check that tells the two apart

failpass·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.