(data, opts)
Decode a BSON string to document_class.
Decode a BSON string to document_class.
Decode a BSON string to document_class .
def _bson_to_dict(data, opts):
    """Decode a BSON string to document_class."""
    try:
        obj_size = _UNPACK_INT(data[:4])[0]
    except struct.error as exc:
        raise InvalidBSON(str(exc))
    if obj_size != len(data):
        raise InvalidBSON("invalid object size")
    if data[obj_size - 1:obj_size] != b"\x00":
        raise InvalidBSON("bad eoo")
    try:
        if _raw_document_class(opts.document_class):
            return opts.document_class(data, opts)
        return _elements_to_dict(data, 4, obj_size - 1, opts)
    except InvalidBSON:
        raise
    except Exception:
        # Change exception type to InvalidBSON but preserve traceback.
        _, exc_value, exc_tb = sys.exc_info()
        reraise(InvalidBSON, exc_value, exc_tb)
def _bson_to_dict ( data , opts ) : try : obj_size = _UNPACK_INT ( data [ : 4 ] ) [ 0 ] except struct . error as exc : raise InvalidBSON ( str ( exc ) ) if obj_size != len ( data ) : raise InvalidBSON ( "invalid object size" ) if data [ obj_size - 1 : obj_size ] != b"\x00" : raise InvalidBSON ( "bad eoo" ) try : if _raw_document_class ( opts . document_class ) : return opts . document_class ( data , opts ) return _elements_to_dict ( data , 4 , obj_size - 1 , opts ) except InvalidBSON : raise except Exception : # Change exception type to InvalidBSON but preserve traceback. _ , exc_value , exc_tb = sys . exc_info ( ) reraise ( InvalidBSON , exc_value , exc_tb )