We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0d600a3 commit e24d5deCopy full SHA for e24d5de
1 file changed
msgpack/fallback.py
@@ -518,9 +518,15 @@ 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):
524
+ key = self._unpack(EX_CONSTRUCT)
525
+ if self._strict_map_key and type(key) not in (str, bytes):
526
+ raise ValueError("%s is not allowed for map key" % str(type(key)))
527
+ yield key, self._unpack(EX_CONSTRUCT)
528
529
+ ret = self._object_pairs_hook(_gen())
530
else:
531
ret = {}
532
for _ in range(n):
0 commit comments