-
Notifications
You must be signed in to change notification settings - Fork 46
Add support for callable class instances #494
Open
Description
Describe your feature request here.
Attempting to call an instance of a class with a __call__ method within JS produces the following error:
TypeError: [object name] is not a function
Callable objects can be detected using PyCallable_Check()
Code example
import pythonmonkey as pm def test_func(): print("test_func") class test_class: def __call__(self): print("test_class") globalThis = pm.eval("globalThis;") globalThis.test_func = test_func globalThis.test_class_instance = test_class() pm.eval("globalThis.test_func()") # This works pm.eval("globalThis.test_class_instance()") # This does not work
Stack Trace
Traceback (most recent call last):
File "[PATH TO FILE].py", line 17, in <module>
pm.eval("globalThis.test_class_instance()") # This does not work
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pythonmonkey.SpiderMonkeyError: Error in file evaluate, on line 1, column 12:
TypeError: globalThis.test_class_instance is not a function
Stack Trace:
@evaluate:1:12
Activity
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
- StatusBacklog