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

Inspecting a JScallback returns an error #66

Closed
sigmaSd opened this issue Jul 14, 2024 · 3 comments · Fixed by #67
Closed

Inspecting a JScallback returns an error #66

sigmaSd opened this issue Jul 14, 2024 · 3 comments · Fixed by #67

Comments

@sigmaSd
Copy link
Contributor

sigmaSd commented Jul 14, 2024

This requires this pr #65 to work, otherwise it will segfault

import { python } from "/home/mrcool/dev/deno/others/deno_python/mod.ts";

const inspect = python.import("inspect");
inspect.signature(python.callback(() => {}));
no signature found for builtin <built-in method JSCallback:anonymous of NoneType object at 0x7f218cf558a0>
error: Uncaught (in promise) PythonError: no signature found for builtin <built-in method JSCallback:anonymous of NoneType object at 0x7f218cf558a0>  File "/usr/lib64/python3.12/inspect.py", line 3335, in signature
    return Signature.from_callable(obj, follow_wrapped=follow_wrapped,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/inspect.py", line 3075, in from_callable
    return _signature_from_callable(obj, sigcls=cls,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/inspect.py", line 2592, in _signature_from_callable
    return _signature_from_builtin(sigcls, obj,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/inspect.py", line 2382, in _signature_from_builtin
    raise ValueError("no signature found for builtin {!r}".format(func))
@DjDeveloperr
Copy link
Member

Looks like we need to setup __signature__ attribute

@sigmaSd
Copy link
Contributor Author

sigmaSd commented Jul 15, 2024

Its not setable,

import { PyObject } from "../others/deno_python/src/python.ts";
import { python } from "/home/mrcool/dev/deno/others/deno_python/mod.ts";

const inspect = python.import("inspect");
const c = PyObject.from(python.callback(() => {}));
c.setAttr("__text_signature__", "hello");

inspect.signature(c);
error: Uncaught (in promise) PythonError: attribute '__text_signature__' of 'builtin_function_or_method' objects is

I feel like the issue is different, the issue is somehow the callbacks are considered builtin despite they're not

@sigmaSd
Copy link
Contributor Author

sigmaSd commented Jul 15, 2024

Actually maybe its normal that its called builtin, since its coming from the c api, so I guess the question is how to add signature attribute

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants