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

Cython relative import error #3003

Open
sploving opened this issue Jun 18, 2019 · 0 comments

Comments

Projects
None yet
1 participant
@sploving
Copy link

commented Jun 18, 2019

There is a example.py in the pkg package. The example.py has a Base class , a Test class and Test2 class.
The contents of the example.py is as the following:

//example.py
class Base(object):
pass

class Test(Base):

def __init__(self):

    super(Test, self).__init__()

    print 'test'

class Test2(Base):

def __init__(self):

    super(Test2, self).__init__()

Then I test it using test.py as the following:

//test.py:

import sys

from pkg.example import Test

sys.path.insert(0, './pkg/')

from example import Test2

Test()

The files structure is as the following:

./test.py

./pkg

./pkg/init.py

./pkg/example.py

When I use Cython to generate an example.so from example.py, and run test.py, it

reports the following error:

Traceback (most recent call last):

File "test.py", line 5, in

Test()

File "pkg/example.py", line 6, in pkg.example.Test.init

TypeError: super(type, obj): obj must be an instance or subtype of type

Any suggestion? Thanks.

Python version is 2.7, Cython Version is 0.29.10

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