MCPcopy Create free account
hub / github.com/go-python/gopy / VarFromHandleTry

Function VarFromHandleTry

gopyh/handle.go:189–203  ·  view source on GitHub ↗

VarFromHandleTry version returns the error explicitly, for use when error can be processed

(h CGoHandle, typnm string)

Source from the content-addressed store, hash-verified

187// VarFromHandleTry version returns the error explicitly,
188// for use when error can be processed
189func VarFromHandleTry(h CGoHandle, typnm string) (interface{}, error) {
190 if h < 1 {
191 return nil, fmt.Errorf("gopy: nil handle")
192 }
193 mu.RLock()
194 defer mu.RUnlock()
195 v, has := handles[GoHandle(h)]
196 if !has {
197 err := fmt.Errorf("gopy: variable handle not registered: " + strconv.FormatInt(int64(h), 10))
198 // TODO: need to get access to this:
199 // C.PyErr_SetString(C.PyExc_TypeError, C.CString(err.Error()))
200 return nil, err
201 }
202 return v, nil
203}
204
205// NumHandles returns the number of handles in use.
206func NumHandles() int {

Callers 1

VarFromHandleFunction · 0.85

Calls 1

GoHandleTypeAlias · 0.85

Tested by

no test coverage detected