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

Function NewModule

pkg/filament/cpython/module.go:47–58  ·  view source on GitHub ↗

NewModule imports a module leaving the globals and locals arguments set to NULL and level set to 0. When the name argument contains a dot (when it specifies a submodule of a package), the fromlist argument is set to the list ['*'] so that the return value is the named module rather than the top-leve

(name string)

Source from the content-addressed store, hash-verified

45// the submodules specified in the package’s __all__ variable are loaded.) Return a new reference to the imported module,
46// or NULL with an exception set on failure. A failing import of a module doesn't leave the module in sys.modules.
47func NewModule(name string) (*Module, error) {
48 n := C.CString(name)
49 defer C.free(unsafe.Pointer(n))
50 mod := C.PyImport_ImportModule(n)
51 if mod == nil {
52 return nil, fmt.Errorf("couldn't import %q module", name)
53 }
54 return &Module{
55 PyObject: &PyObject{rawptr: mod},
56 name: name,
57 }, nil
58}
59
60// MethFlags is the type alias for the method flags
61type MethFlags int

Callers 5

NewFunction · 0.92
initializeIPFnAndClassesFunction · 0.85
TestNewModuleFunction · 0.85
TestModuleRegisterFnFunction · 0.85
FetchErrFunction · 0.85

Calls

no outgoing calls

Tested by 2

TestNewModuleFunction · 0.68
TestModuleRegisterFnFunction · 0.68