I extracted a failing test case here: https://github.com/gmccreight/sqlparse/commit/1cb94246640ac5583f73511d7a47240340a1e583 Is that enough to go on? Please let me know if you'd like me to provide any additional background or explanation. Thanks!