MCPcopy
hub / github.com/pyodide/pyodide / callPyObjectKwargs

Function callPyObjectKwargs

src/core/pyproxy.ts:525–562  ·  view source on GitHub ↗
(ptrobj: number, jsargs: any[], kwargs: any)

Source from the content-addressed store, hash-verified

523// defined in pyproxy.c in JavaScript functions.
524
525function callPyObjectKwargs(ptrobj: number, jsargs: any[], kwargs: any) {
526 // We don't do any checking for kwargs, checks are in PyProxy.callKwargs
527 // which only is used when the keyword arguments come from the user.
528 const num_pos_args = jsargs.length;
529 const kwargs_names = Object.keys(kwargs);
530 const kwargs_values = Object.values(kwargs);
531 const num_kwargs = kwargs_names.length;
532 jsargs.push(...kwargs_values);
533
534 let result;
535 try {
536 Py_ENTER();
537 result = __pyproxy_apply(
538 ptrobj,
539 jsargs,
540 num_pos_args,
541 kwargs_names,
542 num_kwargs,
543 );
544 Py_EXIT();
545 } catch (e) {
546 API.maybe_fatal_error(e);
547 return;
548 }
549 if (result === Module.error) {
550 _pythonexc2js();
551 }
552 // Automatically schedule coroutines
553 if (result && result.type === "coroutine" && result._ensure_future) {
554 Py_ENTER();
555 const is_coroutine = __iscoroutinefunction(ptrobj);
556 Py_EXIT();
557 if (is_coroutine) {
558 result._ensure_future();
559 }
560 }
561 return result;
562}
563
564/**
565 * A version of callPyObjectKwargs that supports the JSPI.

Callers 2

pyproxy.tsFile · 0.85
callKwargsMethod · 0.85

Calls 4

_ensure_futureMethod · 0.80
keysMethod · 0.45
valuesMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…