Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Use StringIO instead of BytesIO for Python 2.5

  • Loading branch information...
commit 54607873bcc1284912f93005136bb739aab9b0da 1 parent 9b67020
Mark Costello authored

Showing 1 changed file with 14 additions and 2 deletions. Show diff stats Hide diff stats

  1. +14 2 rdbtools/parser.py
16 rdbtools/parser.py
@@ -578,8 +578,20 @@ def read_ziplist_entry(self, f) :
578 578
579 579 def read_zipmap(self, f) :
580 580 raw_string = self.read_string(f)
581   - raw_byte_arr = array.array('B', raw_string)
582   - buff = io.BytesIO(raw_byte_arr.tostring())
  581 + bytearray_present = True
  582 + try:
  583 + raw_byte_arr = bytearray(raw_string)
  584 + except NameError:
  585 + raw_byte_arr = array.array('B', raw_string)
  586 + bytearray_present = False
  587 + if bytearray_present:
  588 + byte_str = str(raw_byte_arr)
  589 + else:
  590 + byte_str = raw_byte_arr.tostring()
  591 + try:
  592 + buff = io.BytesIO(byte_str)
  593 + except AttributeError:
  594 + buff = io.StringIO(byte_str)
583 595 num_entries = read_unsigned_char(buff)
584 596 self._callback.start_hash(self._key, num_entries, self._expiry, info={'encoding':'zipmap', 'sizeof_value':len(raw_string)})
585 597 while True :

0 comments on commit 5460787

Please sign in to comment.
Something went wrong with that request. Please try again.