summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDon Anderson <dda@ddanderson.com>2015-07-07 14:57:55 -0400
committerDon Anderson <dda@ddanderson.com>2015-07-07 14:57:55 -0400
commit155fec24f63b3ffb845110d2baed47799c400dd8 (patch)
tree255e694767ef0aedfd8870f244bcba85c6d707bf
parenta94cbadefb0a2138493075b8468b1891340a6896 (diff)
downloadmongo-155fec24f63b3ffb845110d2baed47799c400dd8.tar.gz
Wt-1985. Fixes required by new packing tests:
Specifying 'u' as a format can result in a 'U' format appearing in an index. The pack/unpack routines need to understand 'U'.
-rw-r--r--lang/python/wiredtiger/packing.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/lang/python/wiredtiger/packing.py b/lang/python/wiredtiger/packing.py
index b6f474face8..bda5820a543 100644
--- a/lang/python/wiredtiger/packing.py
+++ b/lang/python/wiredtiger/packing.py
@@ -87,17 +87,18 @@ def unpack(fmt, s):
size = 1
s = s[size:]
# Note: no value, don't increment i
- elif f in 'Ssu':
+ elif f in 'SsUu':
if not havesize:
if f == 's':
size = 1
elif f == 'S':
size = s.find('\0')
- elif f == 'u':
- if offset == len(fmt) - 1:
- size = len(s)
- else:
- size, s = unpack_int(s)
+ elif f == 'u' and offset == len(fmt) - 1:
+ size = len(s)
+ else:
+ # Note: 'U' is used internally, and may be exposed to us.
+ # It indicates that the size is always stored.
+ size, s = unpack_int(s)
result.append(s[:size])
if f == 'S' and not havesize:
size += 1
@@ -132,7 +133,7 @@ def __pack_iter_fmt(fmt, values):
for offset, havesize, size, char in __unpack_iter_fmt(fmt):
if char == 'x': # padding no value
yield offset, havesize, size, char, None
- elif char in 'Ssut':
+ elif char in 'SsUut':
yield offset, havesize, size, char, values[index]
index += 1
else: # integral type
@@ -157,7 +158,7 @@ def pack(fmt, *values):
else:
result += '\0' * size
# Note: no value, don't increment i
- elif f in 'Ssu':
+ elif f in 'SsUu':
if f == 'S' and '\0' in val:
l = val.find('\0')
else:
@@ -167,7 +168,7 @@ def pack(fmt, *values):
l = size
elif f == 's':
havesize = size = 1
- elif f == 'u' and offset != len(fmt) - 1:
+ elif (f == 'u' and offset != len(fmt) - 1) or f == 'U':
result += pack_int(l)
if type(val) is unicode and f in 'Ss':
result += str(val[:l])