This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: inspect getsource does not display full text of lambda
Type: Stage:
Components: Library (Lib) Versions: Python 2.7, Python 2.6
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: Alexey.Spiridonov, georg.brandl
Priority: normal Keywords:

Created on 2013-04-03 23:13 by Alexey.Spiridonov, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (2)
msg185975 - (view) Author: Alexey Spiridonov (Alexey.Spiridonov) Date: 2013-04-03 23:13
This happens because the block search algorithm seems not to be handling lambda arguments correctly.

$ cat x.py
import inspect

def a(y):
    print inspect.getsource(y)
    print inspect.getsourcelines(y)
    
a(
    lambda x:
        x * 
        3
)

$ python x.py
    lambda x:

(['    lambda x:\n'], 8)
msg199773 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2013-10-13 19:34
Unfortunately, this is impossible to fix with the current implementation, which only tokenizes the source.  A full parse would be necessary.

Since this is just a minor inconvenience (and there are many situations where the source cannot be found at all), I'm closing this as won't fix.
History
Date User Action Args
2022-04-11 14:57:43adminsetgithub: 61831
2013-10-13 19:34:39georg.brandlsetstatus: open -> closed

nosy: + georg.brandl
messages: + msg199773

resolution: wont fix
2013-04-03 23:13:59Alexey.Spiridonovcreate