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

__code__ of lambda is None after build #3267

weiliangdashen opened this issue Dec 11, 2019 · 1 comment

__code__ of lambda is None after build #3267

weiliangdashen opened this issue Dec 11, 2019 · 1 comment


Copy link

@weiliangdashen weiliangdashen commented Dec 11, 2019

Hi , It seems\ __code__ can only use for function after build.For lambda, it will become None, the example is:

def func(a,b):
    return a+b
print("func __code__:", func.__code__) 
out : ('func __code__:', <code object func at 0x7f7bc5b71e40, file "", line 2>)

lam = lambda a, b: a+b
print("lam __code__:", lam.__code__)
out : ('lam __code__:', None)

and my is as follows

from Cython.Build import cythonize
from distutils.core import setup


I use python3 build_ext to build and then import .so
is this a bug or I use it wrong, thanks


This comment has been minimized.

Copy link

@scoder scoder commented Dec 24, 2019

Looks like a bug to me. There is no reason why lambdas shouldn't have code objects. Probably just an oversight.
PR welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.