Fixed issue where pickle helpers didnt use new from_bytes with context

- Added with context to benchmarks that use with_bytes
This commit is contained in:
Madhava Jay
2022-05-24 11:38:27 +10:00
parent 26de61d847
commit fc617142c0
5 changed files with 17 additions and 16 deletions

View File

@@ -1099,7 +1099,8 @@ if getattr(_sys, 'subversion', [''])[0] == 'PyPy':
from pickle_helper import _struct_reducer
else:
def _struct_reducer(schema_id, data):
return _global_schema_parser.modules_by_id[schema_id].from_bytes(data)
with _global_schema_parser.modules_by_id[schema_id].from_bytes(data) as msg:
return msg
cdef class _DynamicStructReader:

View File

@@ -3,4 +3,5 @@ import capnp
def _struct_reducer(schema_id, data):
'Hack to deal with pypy not allowing reduce functions to be "built-in" methods (ie. compiled from a .pyx)'
return capnp._global_schema_parser.modules_by_id[schema_id].from_bytes(data)
with capnp._global_schema_parser.modules_by_id[schema_id].from_bytes(data) as msg:
return msg