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 | |
| 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')
| -rw-r--r-- | gitdb/db/loose.py | 3 | ||||
| -rw-r--r-- | gitdb/db/mem.py | 5 | ||||
| -rw-r--r-- | gitdb/test/db/lib.py | 3 |
3 files changed, 8 insertions, 3 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 diff --git a/gitdb/test/db/lib.py b/gitdb/test/db/lib.py index d0028b8..38747de 100644 --- a/gitdb/test/db/lib.py +++ b/gitdb/test/db/lib.py @@ -21,6 +21,7 @@ from gitdb.base import ( from gitdb.exc import BadObject from gitdb.typ import str_blob_type +from gitdb.utils.encoding import force_bytes from async import IteratorReader @@ -97,7 +98,7 @@ class TestDBBase(TestBase): assert info.size == len(data) ostream = db.stream(sha) - assert ostream.read() == data + assert ostream.read() == force_bytes(data) assert ostream.type == str_blob_type assert ostream.size == len(data) else: |
