Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion capnp/includes/capnp_cpp.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ cdef extern from "capnp/schema.h" namespace " ::capnp":
cbool isEnum()
cbool isStruct()
cbool isInterface()
cbool isData()

StructSchema asStruct() except +reraise_kj_exception
EnumSchema asEnum() except +reraise_kj_exception
Expand Down Expand Up @@ -185,7 +186,7 @@ cdef extern from "capnp/schema.h" namespace " ::capnp":
FieldSubset getUnionFields()
FieldSubset getNonUnionFields()

Field getFieldByName(char * name)
Field getFieldByName(char * name) except +reraise_kj_exception

cbool operator == (StructSchema)

Expand Down
5 changes: 2 additions & 3 deletions capnp/lib/capnp.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1879,9 +1879,8 @@ cdef class _DynamicStructBuilder:
for key, val in d.iteritems():
if key != 'which':
if isinstance(val, str):
field = self.schema.fields.get(key)
dtype = field.proto.slot.type.which()
if dtype == "data":
key_bytes = key.encode()
if self.thisptr.getSchema().getFieldByName(key_bytes).getType().isData():
# decode bytes from utf-8 base64 encoding
val = base64.b64decode(val)
try:
Expand Down
Loading