Skip to content

[BUG] __self__ attribute differs on Cython compiled functions #4036

@youmeiyougc

Description

@youmeiyougc
from wrapt import decorator

@decorator
def d1(wrapped, instance, args, kwargs):
    print(f'd1: {args}, {kwargs}')
    return wrapped(*args, **kwargs)

def d2(*argsT, **kwargsT):
    @decorator
    def d3(wrapped, instance, args, kwargs):
        print(f'd3: {argsT}, {kwargsT}, {args}, {kwargs}')
        return wrapped(*args, **kwargs)
    return d3

@d1
@d2(a=int, b=str)
def hello():
    print('hello')

Save above code as hello.py, use another module, import hello and call hello.hello(), all success.

import Cython.Build
import distutils.core
 
def py2c(file):
    cpy = Cython.Build.cythonize(file)
    distutils.core.setup(
	    name = 'test',
	    version = "1.0",
	    ext_modules= cpy,
	    author = "test",
	    author_email='test@163.com'
	)

if __name__ == '__main__':
    file = "hello.py"
    py2c(file)

Save above code as py2c.py, run "python py2c.py build_ext --inplace" ,it generate hello.pyd, import again, raise TypeError.

Expect it run success and print "hello".

  • OS: Windows 7
  • Python version 3.6.8
  • Cython version 0.29.22

raw_code
py2c
exception

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions