We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0d600a3 commit 4e04c8cCopy full SHA for 4e04c8c
1 file changed
msgpack/fallback.py
@@ -518,9 +518,13 @@ def _unpack(self, execute=EX_CONSTRUCT):
518
self._unpack(EX_SKIP)
519
return
520
if self._object_pairs_hook is not None:
521
- ret = self._object_pairs_hook(
522
- (self._unpack(EX_CONSTRUCT), self._unpack(EX_CONSTRUCT)) for _ in range(n)
523
- )
+ def _gen():
+ for _ in range(n):
+ key = self._unpack(EX_CONSTRUCT)
524
+ if self._strict_map_key and type(key) not in (str, bytes):
525
+ raise ValueError("%s is not allowed for map key" % str(type(key)))
526
+ yield key, self._unpack(EX_CONSTRUCT)
527
+ ret = self._object_pairs_hook(_gen())
528
else:
529
ret = {}
530
for _ in range(n):
0 commit comments