  
  def decode_cursor(encoded):
      try:
          offset = int(tokens['offset'][0])
          reverse = bool(int(tokens['reverse'][0]))
          position = tokens['position'][0]
      except (TypeError, ValueError):
          return None
 
</s> remove     tokens = urlparse.parse_qs(b64decode(encoded), keep_blank_values=True)
 </s> add  </s> remove         compare = self.next_position
 </s> add         if self.cursor and self.cursor.reverse and self.cursor.offset != 0:
            # If we're reversing direction and we have an offset cursor
            # then we cannot use the first position we find as a marker.
            compare = self._get_position_from_instance(self.page[-1], self.ordering)
        else:
            compare = self.next_position </s> remove         compare = self.previous_position
 </s> add         if self.cursor and not self.cursor.reverse and self.cursor.offset != 0:
            # If we're reversing direction and we have an offset cursor
            # then we cannot use the first position we find as a marker.
            compare = self._get_position_from_instance(self.page[0], self.ordering)
        else:
            compare = self.previous_position </s> remove             msg = _('Invalid page "{page_number}": {message}.').format(
 </s> add             msg = self.invalid_page_message.format( </s> remove             self.page = reversed(self.page)
 </s> add             self.page = list(reversed(self.page))
        tokens = urlparse.parse_qs(b64decode(encoded), keep_blank_values=True)
  
  def decode_cursor(encoded):
      try:
        tokens = urlparse.parse_qs(b64decode(encoded), keep_blank_values=True)
          offset = int(tokens['offset'][0])
          reverse = bool(int(tokens['reverse'][0]))
          position = tokens['position'][0]
      except (TypeError, ValueError):
          return None
keep keep add keep keep keep keep keep
 Tidy up cursor tests and make more comprehensive 
rest_framework/pagination.py