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

Method String

pkg/filament/cpython/object.go:271–286  ·  view source on GitHub ↗

String encodes an Unicode object and returns the result as a Python bytes object converted to the Go string.

()

Source from the content-addressed store, hash-verified

269
270// String encodes an Unicode object and returns the result as a Python bytes object converted to the Go string.
271func (ob *PyObject) String() string {
272 if ob.rawptr == nil {
273 return ""
274 }
275 repr := C.PyObject_Str(ob.rawptr)
276 if repr == nil {
277 return ""
278 }
279 defer C.Py_DecRef(repr)
280 s := C.PyUnicode_AsEncodedString(repr, encoding, codecErrors)
281 if s == nil {
282 return "invalid Unicode string"
283 }
284 defer C.Py_DecRef(s)
285 return C.GoString(C.PyBytes_AsString(s))
286}
287
288// StringSlice returns this object as a string slice.
289func (ob *PyObject) StringSlice() []string {

Callers 1

FetchErrFunction · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected