-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
Milestone
Description
I'm using Cython version 0.29.7.
Part of the error message (full message attached: output.txt):
AA/bug.c:830:57: error: expected identifier or ‘(’ before ‘.’ token
struct __pyx_obj_2AA_3bug___pyx_scope_struct____pyx_base.func;
Here's a quick example to reproduce, including a workaround.
# cython: language_level=3
cdef class FBase():
def __init__(self):
pass
def __cinit__(self):
pass
cdef func(self, whatever):
pass
cdef class Bug(FBase):
def __init__(self):
pass
cdef check(self, x):
return x
cdef func(self, whatever):
a = [1, 2, 3]
min(a, key=lambda x: self.check(x))
# This generates correct C, but doesn't work in Python:
# min(a, key=lambda self, x: self.check(x))
# Workaround:
# import functools
# min(a, key=functools.partial(lambda self, x: self.check(x), self))
Reactions are currently unavailable