From 40aa964057746c0e8f913228de95973a46ee3c0e Mon Sep 17 00:00:00 2001 From: Jared Junyoung Lim Date: Wed, 14 Dec 2022 14:42:56 -0800 Subject: [PATCH] Add Ref.AsStringBytes to flatbuffers.flexbuffers Python API (#7713) * Add Ref.AsStringBytes to flatbuffers.flexbuffers Python API * Append Bytes to AsStringBytes return value Co-authored-by: Jared Junyoung Lim --- python/flatbuffers/flexbuffers.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/python/flatbuffers/flexbuffers.py b/python/flatbuffers/flexbuffers.py index da10668a4..aaa02fdaf 100644 --- a/python/flatbuffers/flexbuffers.py +++ b/python/flatbuffers/flexbuffers.py @@ -727,6 +727,15 @@ class Ref: def IsString(self): return self._type is Type.STRING + @property + def AsStringBytes(self): + if self.IsString: + return String(self._Indirect(), self._byte_width).Bytes + elif self.IsKey: + return self.AsKeyBytes + else: + raise self._ConvertError(Type.STRING) + @property def AsString(self): if self.IsString: