summaryrefslogtreecommitdiff
path: root/lang
diff options
context:
space:
mode:
authorMichael Cahill <michael.cahill@mongodb.com>2016-01-20 15:26:17 +1100
committerMichael Cahill <michael.cahill@mongodb.com>2016-01-20 15:26:17 +1100
commitfb2cc399f45a9106124738198d16d2fa13331019 (patch)
treee0f89ef4119367ee5d55e09c1df7866b549e485b /lang
parentba9ac383d010451f55b5d0cb7acef25e8700d095 (diff)
parent6bd6dea47c05d48784b48f90df9885cedd48e6a9 (diff)
downloadmongo-fb2cc399f45a9106124738198d16d2fa13331019.tar.gz
Merge pull request #2441 from wiredtiger/WT-1517
WT-1517: schema format edge cases
Diffstat (limited to 'lang')
-rw-r--r--lang/python/wiredtiger/packing.py16
1 files changed, 4 insertions, 12 deletions
diff --git a/lang/python/wiredtiger/packing.py b/lang/python/wiredtiger/packing.py
index 2012263e258..5d21b539888 100644
--- a/lang/python/wiredtiger/packing.py
+++ b/lang/python/wiredtiger/packing.py
@@ -70,6 +70,8 @@ def __unpack_iter_fmt(fmt):
size = (size * 10) + int(char)
havesize = 1
else:
+ if not havesize:
+ size = 1
yield offset, havesize, size, char
size = 0
havesize = 0
@@ -83,14 +85,12 @@ def unpack(fmt, s):
result = []
for offset, havesize, size, f in __unpack_iter_fmt(fmt):
if f == 'x':
- if not havesize:
- size = 1
s = s[size:]
# Note: no value, don't increment i
elif f in 'SsUu':
if not havesize:
if f == 's':
- size = 1
+ pass
elif f == 'S':
size = s.find('\0')
elif f == 'u' and offset == len(fmt) - 1:
@@ -106,14 +106,10 @@ def unpack(fmt, s):
s = s[size:]
elif f in 't':
# bit type, size is number of bits
- if not havesize:
- size = 1
result.append(ord(s[0:1]))
s = s[1:]
elif f in 'Bb':
# byte type
- if not havesize:
- size = 1
for i in xrange(size):
v = ord(s[0:1])
if f != 'B':
@@ -122,8 +118,6 @@ def unpack(fmt, s):
s = s[1:]
else:
# integral type
- if not havesize:
- size = 1
for j in xrange(size):
v, s = unpack_int(s)
result.append(v)
@@ -164,11 +158,9 @@ def pack(fmt, *values):
l = val.find('\0')
else:
l = len(val)
- if havesize:
+ if havesize or f == 's':
if l > size:
l = size
- elif f == 's':
- havesize = size = 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':