No eoc when using xget and column_finish with fewer items than the composite type #167

Closed
bbgordonn opened this Issue Jul 27, 2012 · 2 comments

Comments

Projects
None yet
2 participants

In pycassa 1.7.0:

print cf.column_name_class  # CompositeType(AsciiType, AsciiType)
print dict(cf.xget("xxx", column_finish=("yyy",)))

Produces:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/tmp/pycassa/columnfamily.py", line 537, in xget
    finish = self._pack_name(column_finish)
  File "/tmp/pycassa/columnfamily.py", line 420, in _pack_name
    return self._name_packer(value, slice_start)
  File "/tmp/pycassa/marshal.py", line 122, in pack_composite
    s += ''.join((len_packer(len(packed)), packed, eoc))
UnboundLocalError: local variable 'eoc' referenced before assignment

This appears to be related to #137 because xget(), unlike get(), does not explicitly set slice_start based on column_reversed when calling _pack_name?

I think this patch is the equivalent to the change that was made to get()

diff a/pycassa/columnfamily.py b/pycassa/columnfamily.py
--- a/pycassa/columnfamily.py
+++ b/pycassa/columnfamily.py
@@ -532,9 +532,11 @@ class ColumnFamily(object):
         count = i = 0
         last_name = finish = ""
         if column_start != "":
-            last_name = self._pack_name(column_start)
+            last_name = self._pack_name(column_start,
+                                        slice_start=(not column_reversed))
         if column_finish != "":
-            finish = self._pack_name(column_finish)
+            finish = self._pack_name(column_finish,
+                                     slice_start=column_reversed)

         while True:
             if column_count is not None:

@thobbs thobbs closed this in 65af172 Aug 19, 2012

Owner

thobbs commented Aug 19, 2012

That should fix it, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment