Things to check first
Typeguard version
4.4.3
Python version
3.11
What happened?
In 4.4.3, the typechecked decorator can crash with "IndexError: list index out of range". This can be triggered by using it on two functions of the same name with list comprehensions inside (which is ok in 4.4.2). It looks to me like the crash is because the changes in c5d91e9 removed a check in find_target_function() on the new target path being non-empty before the recursive call.
How can we reproduce the bug?
from typeguard import typechecked
@typechecked
def f():
return [0 for v in range(10)]
@typechecked
def f():
return [1 for v in range(10)]
File "[...]/venv/lib/python3.11/site-packages/typeguard/_decorators.py", line 42, in find_target_function
target_path[1:] if const.co_name == target_path[0] else target_path
~~~~~~~~~~~^^^
IndexError: list index out of range
Things to check first
I have searched the existing issues and didn't find my bug already reported there
I have checked that my bug is still present in the latest release
Typeguard version
4.4.3
Python version
3.11
What happened?
In 4.4.3, the
typecheckeddecorator can crash with "IndexError: list index out of range". This can be triggered by using it on two functions of the same name with list comprehensions inside (which is ok in 4.4.2). It looks to me like the crash is because the changes in c5d91e9 removed a check infind_target_function()on the new target path being non-empty before the recursive call.How can we reproduce the bug?