summaryrefslogtreecommitdiff
path: root/lang
diff options
context:
space:
mode:
authorDon Anderson <dda@mongodb.com>2017-05-25 14:48:26 -0400
committerAlex Gorrod <alexander.gorrod@mongodb.com>2017-05-25 14:48:26 -0400
commitdb14d312f68769f358662f5ea7aa74d61b9cd35d (patch)
tree88f1497f545045c4529ecf9518dc7c3213a26059 /lang
parent4641a4586fd18925b3e91881b7c5fd7a203c337b (diff)
downloadmongo-db14d312f68769f358662f5ea7aa74d61b9cd35d.tar.gz
WT-3333 Fixes for zero length strings packed/unpacked in a 'u' format via Python. (#3432)
Diffstat (limited to 'lang')
-rw-r--r--lang/python/wiredtiger/packing.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/lang/python/wiredtiger/packing.py b/lang/python/wiredtiger/packing.py
index 0506f2afda9..fb674538b76 100644
--- a/lang/python/wiredtiger/packing.py
+++ b/lang/python/wiredtiger/packing.py
@@ -94,6 +94,9 @@ def unpack(fmt, s):
elif f == 'S':
size = s.find('\0')
elif f == 'u' and offset == len(fmt) - 1:
+ # A WT_ITEM with a NULL data field will be appear as None.
+ if s == None:
+ s = ''
size = len(s)
else:
# Note: 'U' is used internally, and may be exposed to us.
@@ -169,7 +172,7 @@ def pack(fmt, *values):
result += val[:l]
if f == 'S' and not havesize:
result += '\0'
- elif size > l:
+ elif size > l and havesize:
result += '\0' * (size - l)
elif f in 't':
# bit type, size is number of bits