Add support for Cythonized API Classes #2029
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce?
What is the related issue number (starting with
#
)#1814
What is the current behavior? (You can also link to an open issue here)
Currently, when an API class is cythonized, the methods for the class do not pass the decoratable_types check. The issue #1814 was raised 5 years ago and is still relevant.
What is the new behavior (if this is a feature change)?
Cythonized API class methods are getting mounted in cherrypy.tree and the API runs successfully.
Other information:
I tried the approach suggested by @webknjaz to put the types.BuiltinFunctionType in the decoratable_types, however, not all cythonized methods are of types.BuiltinFunctionType. The one thing these functions have in common is the "func_code" attribute.
As for the testing of this change, I am still looking into it. Currently, I can only come up with one way where I create a .whl file and install the cythonized API as a package, then import from the package and test if CherryPy is working, but this way does not seem very efficient.
At worst, the hasattr check may fail in later python versions (very unlikely since func_code is a core cython method attribute). This feature is important for people who want to speedup and package their code using Cython.
Checklist:
and description in grammatically correct, complete sentences