summaryrefslogtreecommitdiff
path: root/gitdb/util.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2015-01-06 17:02:35 +0100
committerSebastian Thiel <byronimo@gmail.com>2015-01-06 17:02:35 +0100
commitfdc1d68b01f0d5dd601cdcc29df0eee19787d7c9 (patch)
treee2a950d95009cfd94e79fb59358d4ba0a575a221 /gitdb/util.py
parentb1c9d3eb5b13f2feecb242701f5b4842184f6234 (diff)
downloadgitdb-0.6.2.tar.gz
Fixed python 3 compatibility issue that only showed on windows0.6.2
And bumped version to 0.6.2
Diffstat (limited to 'gitdb/util.py')
-rw-r--r--gitdb/util.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/gitdb/util.py b/gitdb/util.py
index 5b451fa..8f80156 100644
--- a/gitdb/util.py
+++ b/gitdb/util.py
@@ -8,7 +8,7 @@ import mmap
import sys
import errno
-from io import StringIO
+from io import BytesIO
from smmap import (
StaticWindowMapManager,
@@ -78,14 +78,14 @@ from gitdb.const import (
#{ compatibility stuff ...
-class _RandomAccessStringIO(object):
+class _RandomAccessBytesIO(object):
"""Wrapper to provide required functionality in case memory maps cannot or may
not be used. This is only really required in python 2.4"""
__slots__ = '_sio'
def __init__(self, buf=''):
- self._sio = StringIO(buf)
+ self._sio = BytesIO(buf)
def __getattr__(self, attr):
return getattr(self._sio, attr)
@@ -130,7 +130,7 @@ def make_sha(source=''.encode("ascii")):
def allocate_memory(size):
""":return: a file-protocol accessible memory block of the given size"""
if size == 0:
- return _RandomAccessStringIO('')
+ return _RandomAccessBytesIO(b'')
# END handle empty chunks gracefully
try:
@@ -140,7 +140,7 @@ def allocate_memory(size):
# this of course may fail if the amount of memory is not available in
# one chunk - would only be the case in python 2.4, being more likely on
# 32 bit systems.
- return _RandomAccessStringIO("\0" * size)
+ return _RandomAccessBytesIO(b"\0" * size)
# END handle memory allocation
@@ -169,7 +169,7 @@ def file_contents_ro(fd, stream=False, allow_mmap=True):
# read manully
contents = os.read(fd, os.fstat(fd).st_size)
if stream:
- return _RandomAccessStringIO(contents)
+ return _RandomAccessBytesIO(contents)
return contents