You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I do not think that restoring that regexp is a correct solution. This method has proven unreliable. And even if it works, it will show the source of the first function or class above the generator expression. It may even not include the source of the generator expression.
I think that the right method is to fix getblock(), so it will process generator expressions similarly to lambda expressions.
Activity
George-Ogden commentedon Aug 6, 2025
Possibly related to #122981
Introduced in #117025
[-]`inspect.getsourcelines` bug introduced in #117025[/-][+]`inspect.getsourcelines()` Bug[/+]AA-Turner commentedon Aug 6, 2025
cc @gaogaotiantian
pythongh-137477: Fix inspect.getblock() for generator expressions
serhiy-storchaka commentedon Aug 6, 2025
I do not think that restoring that regexp is a correct solution. This method has proven unreliable. And even if it works, it will show the source of the first function or class above the generator expression. It may even not include the source of the generator expression.
I think that the right method is to fix
getblock(), so it will process generator expressions similarly to lambda expressions.George-Ogden commentedon Aug 7, 2025
@serhiy-storchaka I think #137488 is a better solution than #137479
[-]`inspect.getsourcelines()` Bug[/-][+]`inspect.getsourcelines()` mishandles multi-line generator expressions[/+]gh-137477: Fix inspect.getblock() for generator expressions (GH-137488)
pythongh-137477: Fix inspect.getblock() for generator expressions (py…
[3.13] pythongh-137477: Fix inspect.getblock() for generator expressi…
[3.13] gh-137477: Fix inspect.getblock() for generator expressions (G…
[3.14] gh-137477: Fix inspect.getblock() for generator expressions (G…