Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Token matching generates an exception when index is None #747

Open
barsa-net opened this issue Nov 10, 2023 · 0 comments
Open

Token matching generates an exception when index is None #747

barsa-net opened this issue Nov 10, 2023 · 0 comments

Comments

@barsa-net
Copy link

barsa-net commented Nov 10, 2023

Describe the bug
Using token_matching with index None generates an TypeError exception

To Reproduce
Executing the following code

import sqlparse

p = sqlparse.parse("SELECT id FROM table")[0]
p.token_matching([lambda x: isinstance(x, sqlparse.sql.Token)], None)

generates an exception

Traceback (most recent call last):
  File "/repositories/github/sqlparse/t.py", line 4, in <module>
    p.token_matching(lambda x: isinstance(x, sqlparse.sql.Token), None)
  File "/repositories/github/sqlparse/sqlparse/sql.py", line 277, in token_matching
    return self._token_matching(funcs, idx)[1]
TypeError: 'NoneType' object is not subscriptable

Expected behavior
token_matching should return None

Versions (please complete the following information):

  • Python: 3.9.18
  • sqlparse: git commit f101546
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant