diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2015-01-05 10:09:51 +0100 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2015-01-05 10:09:51 +0100 |
commit | bc8c91200a7fb2140aadd283c66b5ab82f9ad61e (patch) | |
tree | 54f8b4e09ae36f465da25ecd16d6377a2a8414a8 /git/index | |
parent | ae2ff0f9d704dc776a1934f72a339da206a9fff4 (diff) | |
download | gitpython-py3.tar.gz |
Fixed io types to make tests work on PY2 once again.py3
Now it's about going through PY3 issues
Diffstat (limited to 'git/index')
-rw-r--r-- | git/index/base.py | 6 | ||||
-rw-r--r-- | git/index/fun.py | 4 |
2 files changed, 6 insertions, 4 deletions
diff --git a/git/index/base.py b/git/index/base.py index 25ac121c..a994e7b6 100644 --- a/git/index/base.py +++ b/git/index/base.py @@ -8,7 +8,7 @@ import os import sys import subprocess import glob -from io import StringIO +from io import BytesIO from stat import S_ISLNK @@ -43,6 +43,7 @@ from git.compat import ( izip, xrange, string_types, + force_bytes ) from git.util import ( @@ -562,7 +563,8 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): st = os.lstat(filepath) # handles non-symlinks as well stream = None if S_ISLNK(st.st_mode): - stream = StringIO(os.readlink(filepath)) + # in PY3, readlink is string, but we need bytes. In PY2, it's just OS encoded bytes, we assume UTF-8 + stream = BytesIO(force_bytes(os.readlink(filepath), encoding='utf-8')) else: stream = open(filepath, 'rb') # END handle stream diff --git a/git/index/fun.py b/git/index/fun.py index 004f992e..0e49ae8d 100644 --- a/git/index/fun.py +++ b/git/index/fun.py @@ -12,7 +12,7 @@ from stat import ( S_IFGITLINK = S_IFLNK | S_IFDIR # a submodule -from io import StringIO +from io import BytesIO from git.util import IndexFileSHA1Writer from git.exc import UnmergedEntriesError @@ -218,7 +218,7 @@ def write_tree_from_cache(entries, odb, sl, si=0): # END for each entry # finally create the tree - sio = StringIO() + sio = BytesIO() tree_to_stream(tree_items, sio.write) sio.seek(0) |