-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
Milestone
Description
Hello up there. Please consider the following example:
---- 8< ---- moda.pxd
cdef class MyClass:
@staticmethod
cdef static_func(x)---- 8< ---- moda.pyx
cdef class MyClass:
@staticmethod
cdef static_func(x):
return x+1---- 8< ---- modb.pyx
from moda cimport MyClass
def test():
x = MyClass.static_func(2)
print(x)When compiled and run it fails with:
$ python -c 'import modb; modb.test()'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "modb.pyx", line 4, in modb.test
x = MyClass.static_func(2)
TypeError: Cannot convert int to moda.MyClass
If I add explicit object to x argument in moda.pxd:
--- a/moda.pxd
+++ b/moda.pxd
@@ -1,3 +1,3 @@
cdef class MyClass:
@staticmethod
- cdef static_func(x)
+ cdef static_func(object x)
It works:
$ python -c 'import modb; modb.test()'
3
Thanks beforehand,
Kirill
/cc @robertwb