diff options
| author | Sebastian Thiel <byronimo@gmail.com> | 2015-01-06 18:26:18 +0100 |
|---|---|---|
| committer | Sebastian Thiel <byronimo@gmail.com> | 2015-01-06 18:26:18 +0100 |
| commit | de96c522ff20fa99d13128784a393b619dd0b33b (patch) | |
| tree | 7fabd5dc369ed2dded19126fb70a5ae7ca9adf5e /gitdb/utils | |
| parent | cb72f81e1407a86d85215a7fba4c2905c2451e0c (diff) | |
| download | gitdb-de96c522ff20fa99d13128784a393b619dd0b33b.tar.gz | |
Fixed yet another issue with smmap's latest changes
Now we deal with memory views as well ...
Diffstat (limited to 'gitdb/utils')
| -rw-r--r-- | gitdb/utils/compat.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/gitdb/utils/compat.py b/gitdb/utils/compat.py index c08cab5..a7899cb 100644 --- a/gitdb/utils/compat.py +++ b/gitdb/utils/compat.py @@ -15,6 +15,9 @@ try: # Python 2 buffer = buffer memoryview = buffer + # Assume no memory view ... + def to_bytes(i): + return i except NameError: # Python 3 has no `buffer`; only `memoryview` # However, it's faster to just slice the object directly, maybe it keeps a view internally @@ -26,6 +29,11 @@ except NameError: # return memoryview(obj)[offset:offset+size] return obj[offset:offset + size] # end buffer reimplementation + # smmap can return memory view objects, which can't be compared as buffers/bytes can ... + def to_bytes(i): + if isinstance(i, memoryview): + return i.tobytes() + return i memoryview = memoryview |
