diff options
author | Don Anderson <dda@ddanderson.com> | 2014-11-12 15:06:36 -0500 |
---|---|---|
committer | Don Anderson <dda@ddanderson.com> | 2014-11-12 15:06:36 -0500 |
commit | de0725b54663512ad4f811cdc99e3f7b03f51f24 (patch) | |
tree | 652fc7ba20af71416073e5e91aaddaa56aba7576 /lang | |
parent | 4e4bf47f212a37180116bf676839f5abe045cc7d (diff) | |
download | mongo-de0725b54663512ad4f811cdc99e3f7b03f51f24.tar.gz |
Allow unicode typed objects in Python with S/s formats. refs #1187.
Includes tests that trigger the problem.
Diffstat (limited to 'lang')
-rw-r--r-- | lang/python/wiredtiger/packing.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lang/python/wiredtiger/packing.py b/lang/python/wiredtiger/packing.py index a79bf6bffbd..3ad4623e2f1 100644 --- a/lang/python/wiredtiger/packing.py +++ b/lang/python/wiredtiger/packing.py @@ -109,10 +109,11 @@ def pack(fmt, *values): result += '\0' * size # Note: no value, don't increment i elif f in 'Ssu': - if f == 'S' and '\0' in values[i]: - l = values[i].find('\0') + val = values[i] + if f == 'S' and '\0' in val: + l = val.find('\0') else: - l = len(values[i]) + l = len(val) if havesize: if l > size: l = size @@ -120,7 +121,10 @@ def pack(fmt, *values): havesize = size = 1 elif f == 'u' and offset != len(fmt) - 1: result += pack_int(l) - result += values[i][:l] + if type(val) is unicode and f in 'Ss': + result += str(val[:l]) + else: + result += val[:l] if f == 'S' and not havesize: result += '\0' elif size > l: |