Whole file

andialbrecht/sqlparse

The author described this change as Raise SQLParseError instead of RecursionError.. It counts as a record because the check below fails on the code as it stood at f1bcf2f8a and passes on b4a39d985, with nothing else changed between the two runs.

Fix saved2024-04-13
Sharing licenceBSD-3-Clause · LICENSE
Change size+9 5

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

Raise SQLParseError instead of RecursionError.

The change

1010 import re
1111
1212 from sqlparse import tokens as T
13+from sqlparse.exceptions import SQLParseError
1314 from sqlparse.utils import imt, remove_quotes
1415
1516
209210
210211 This method is recursively called for all child tokens.
211212 """
212- for token in self.tokens:
213- if token.is_group:
214- yield from token.flatten()
215- else:
216- yield token
213+ try:
214+ for token in self.tokens:
215+ if token.is_group:
216+ yield from token.flatten()
217+ else:
218+ yield token
219+ except RecursionError as err:
220+ raise SQLParseError('Maximum recursion depth exceeded') from err
217221
218222 def get_sublists(self):
219223 for token in self.tokens:

The check that tells the two apart

failpass·tests/test_regressions.py::test_max_recursion

Check file tests/test_regressions.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 itf1bcf2f8a7ddf6854c99990c56ff5394f4981d58
Broken version dated2024-04-13
Modulesqlparse.sql
Units changedTokenList
Fingerprint44f25e3c8506e26f
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 andialbrecht/sqlparse