Whole file

terryyin/lizard

The author described this change as Fixing bug when python has multiple line for function declaration due to formatting (#319). It counts as a record because the check below fails on the code as it stood at 79ecdc28d and passes on c900ecc9b, with nothing else changed between the two runs.

Fix saved2021-05-31
Sharing licenceMIT · LICENSE.txt
Change size+3 3

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

Fixing bug when python has multiple line for function declaration due to formatting (#319)

The change

1313 self.indents = [0]
1414 self.context = context
1515
16- def set_nesting(self, spaces):
17- while self.indents[-1] > spaces:
16+ def set_nesting(self, spaces, token = ""):
17+ while self.indents[-1] > spaces and (not token.startswith(")")):
1818 self.indents.pop()
1919 self.context.pop_nesting()
2020 if self.indents[-1] < spaces:
5353 current_leading_spaces += count_spaces(token)
5454 else:
5555 if not token.startswith('#'):
56- indents.set_nesting(current_leading_spaces)
56+ indents.set_nesting(current_leading_spaces, token)
5757 reading_leading_space = False
5858 else:
5959 reading_leading_space = True

The check that tells the two apart

failpass·test/test_languages/testPython.py::Test_parser_for_Python::test_multi_line_function_def_function_end

Check file test/test_languages/testPython.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 it79ecdc28ddbd313358ecc79971add3f8dafa088c
Broken version dated2021-05-14
Modulelizard_languages.python
Units changedPythonIndents, PythonReader
Fingerprint2f25ca6bead08153
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 terryyin/lizard