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.
Projectandialbrecht/sqlparse
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
| 10 | 10 | import re | |
| 11 | 11 | ||
| 12 | 12 | from sqlparse import tokens as T | |
| 13 | + | from sqlparse.exceptions import SQLParseError | |
| 13 | 14 | from sqlparse.utils import imt, remove_quotes | |
| 14 | 15 | ||
| 15 | 16 | ||
| ⋯ | |||
| 209 | 210 | ||
| 210 | 211 | This method is recursively called for all child tokens. | |
| 211 | 212 | """ | |
| 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 | |
| 217 | 221 | ||
| 218 | 222 | def get_sublists(self): | |
| 219 | 223 | for token in self.tokens: | |
The check that tells the two apart
fail→pass·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
- 2026-07-25Fix get_real_name for names with more than two dotted parts (#332)
- 2026-07-22Fix function grouping skipped for lowercase 'as' in CREATE TABLE AS SELECT
- 2025-11-29StatementSplitter
- 2025-11-28StatementSplitter
- 2024-07-15StatementSplitter
- 2024-04-13Fix Function.get_parameters(), add Funtion.get_window()