MCPcopy Create free account
hub / github.com/rabbitstack/fibratus / CallableArgCount

Method CallableArgCount

pkg/filament/cpython/object.go:350–362  ·  view source on GitHub ↗

CallableArgCount returns the number of arguments declared in the callable Python object.

()

Source from the content-addressed store, hash-verified

348
349// CallableArgCount returns the number of arguments declared in the callable Python object.
350func (ob *PyObject) CallableArgCount() uint32 {
351 fnCode, err := ob.GetAttrString("__code__")
352 if err != nil || fnCode.IsNull() {
353 return 0
354 }
355 defer fnCode.DecRef()
356 count, err := fnCode.GetAttrString("co_argcount")
357 if err != nil {
358 return 0
359 }
360 defer count.DecRef()
361 return count.Uint32()
362}
363
364// Call calls a callable Python object with arguments given by the tuple args. If no arguments are needed, then args
365// may be NULL. Returns the result of the call on success, or a null reference on failure.

Callers 1

NewFunction · 0.80

Calls 4

GetAttrStringMethod · 0.95
IsNullMethod · 0.80
DecRefMethod · 0.80
Uint32Method · 0.80

Tested by

no test coverage detected