Skip to content

Commit fe929a5

Browse files
committed
fix: skip schema lookup when value is not a str
Since 8467490 (#351, "added binary support in dictionaries via base64 encoding"), `_DynamicStructBuilder.from_dict` does a `self.schema.fields.get(key)` lookup for every key in the input dict. The lookup was added so that `str` values destined for a `Data` field can be base64-decoded, but the lookup itself runs unconditionally, even when the value is `bool`, `int`, `dict`, `list`, `bytes`, etc.
1 parent 76a41c8 commit fe929a5

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

capnp/lib/capnp.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1738,8 +1738,8 @@ cdef class _DynamicStructBuilder:
17381738
def from_dict(self, dict d):
17391739
for key, val in d.iteritems():
17401740
if key != 'which':
1741-
field = self.schema.fields.get(key)
17421741
if isinstance(val, str):
1742+
field = self.schema.fields.get(key)
17431743
dtype = field.proto.slot.type.which()
17441744
if dtype == "data":
17451745
# decode bytes from utf-8 base64 encoding

0 commit comments

Comments
 (0)