vardbapi._owners_cache._hash_str(), use 'backslashreplace' in order to avoid
potential UnicodeError exceptions. Use constant ascii and utf_8 codecs,
respectively, since these codecs are guaranteed to be available by
_ensure_default_encoding().
svn path=/main/trunk/; revision=12689
counter, = self.aux_get(cpv, aux_keys)
except KeyError:
continue
- h.update(counter.encode())
+ h.update(counter.encode('ascii', 'backslashreplace'))
return h.hexdigest()
def cpv_inject(self, mycpv):
def _hash_str(self, s):
h = self._new_hash()
- h.update(s.encode())
+ # Always use a constant utf_8 encoding here, since
+ # the "default" encoding can change.
+ h.update(s.encode('utf_8', 'backslashreplace'))
h = h.hexdigest()
h = h[-self._hex_chars:]
h = int(h, 16)