MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / _get_string

Function _get_string

bson/__init__.py:282–293  ·  view source on GitHub ↗

Decode a BSON string to python str.

(
    data: Any, view: Any, position: int, obj_end: int, opts: CodecOptions[Any], dummy: Any
)

Source from the content-addressed store, hash-verified

280
281
282def _get_string(
283 data: Any, view: Any, position: int, obj_end: int, opts: CodecOptions[Any], dummy: Any
284) -> Tuple[str, int]:
285 """Decode a BSON string to python str."""
286 length = _UNPACK_INT_FROM(data, position)[0]
287 position += 4
288 if length < 1 or obj_end - position < length:
289 raise InvalidBSON("invalid string length")
290 end = position + length - 1
291 if data[end] != 0:
292 raise InvalidBSON("invalid end of string")
293 return _utf_8_decode(view[position:end], opts.unicode_decode_error_handler, True)[0], end + 1
294
295
296def _get_object_size(data: Any, position: int, obj_end: int) -> Tuple[int, int]:

Callers 3

_get_codeFunction · 0.85
_get_code_w_scopeFunction · 0.85
_get_refFunction · 0.85

Calls 1

InvalidBSONClass · 0.90

Tested by

no test coverage detected