diff options
| author | Kevin Brown <kevin@kevinbrown.in> | 2014-07-16 20:36:02 -0400 |
|---|---|---|
| committer | Kevin Brown <kevin@kevinbrown.in> | 2014-07-16 20:36:02 -0400 |
| commit | ecdae96cdb8bbde322f59fd119dab302e7797c18 (patch) | |
| tree | a52dc56b4d749c5ea264d4c8ab96b8140d92bfab /gitdb/db | |
| parent | 0465cf327d232101b2de69d714a468b7e1a66a74 (diff) | |
| download | gitdb-ecdae96cdb8bbde322f59fd119dab302e7797c18.tar.gz | |
Fixed a few more encoding issues
Bytes should always be returned from the streams, so the tests
should be checking against byte strings instead of text strings.
This also fixes the `sha_iter` as it relied on the Python 2
`iterkeys` which has been renamed to `keys` in Python 3.
Diffstat (limited to 'gitdb/db')
| -rw-r--r-- | gitdb/db/loose.py | 3 | ||||
| -rw-r--r-- | gitdb/db/mem.py | 5 |
2 files changed, 6 insertions, 2 deletions
diff --git a/gitdb/db/loose.py b/gitdb/db/loose.py index f66d627..63f9635 100644 --- a/gitdb/db/loose.py +++ b/gitdb/db/loose.py @@ -52,6 +52,7 @@ from gitdb.fun import ( ) from gitdb.utils.compat import MAXSIZE +from gitdb.utils.encoding import force_bytes import tempfile import mmap @@ -116,7 +117,7 @@ class LooseObjectDB(FileDBBase, ObjectDBR, ObjectDBW): :raise BadObject: """ candidate = None for binsha in self.sha_iter(): - if bin_to_hex(binsha).startswith(partial_hexsha): + if bin_to_hex(binsha).startswith(force_bytes(partial_hexsha)): # it can't ever find the same object twice if candidate is not None: raise AmbiguousObjectName(partial_hexsha) diff --git a/gitdb/db/mem.py b/gitdb/db/mem.py index efd85af..a224546 100644 --- a/gitdb/db/mem.py +++ b/gitdb/db/mem.py @@ -86,7 +86,10 @@ class MemoryDB(ObjectDBR, ObjectDBW): return len(self._cache) def sha_iter(self): - return self._cache.iterkeys() + try: + return self._cache.iterkeys() + except AttributeError: + return self._cache.keys() #{ Interface |
