-
Type: Bug
-
Resolution: Works as Designed
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Language Bindings
-
None
-
1
-
Storage Engines 2020-01-13
Using the wiredtiger Python library to decode a MongoDB sizeStorer table results in an encoding error in Python 3.7:
Traceback (most recent call last):
File "sizeStorer.py", line 31, in <module>
size = sizeStorer[ident]
File ".../python3.7/site-packages/wiredtiger/wiredtiger.py", line 441, in _getitem_
self.set_key(key)
File ".../python3.7/site-packages/wiredtiger/wiredtiger.py", line 410, in set_key
self._key = pack(self.key_format, *args)
File ".../python3.7/site-packages/wiredtiger/packing.py", line 183, in pack
result += val[:l]
TypeError: can't concat str to bytes
The logic in wiredtiger's packing.py tries to add a string value to a result string which is bytes:
if _is_string(val) and f in 'Ss': result += str(val[:l]).encode() else: result += val[:l]
The sizeStorer values are apparently strings with "u" format, so match the else condition rather than the if (which would not result in an error).
Attached is a script to repro the issue. The error was consistent with new dbpaths created in MongoDB 3.6 and 4.2 using --directoryperdb.