| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,7 +16,8 @@ | |||
| 16 | 16 | ||
| 17 | 17 | from gitdb.utils.encoding import ( | |
| 18 | 18 | string_types, | |
| 19 | - text_type | ||
| 19 | + text_type, | ||
| 20 | + force_bytes | ||
| 20 | 21 | ) | |
| 21 | 22 | ||
| 22 | 23 | if PY3: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,7 +8,7 @@ | |||
| 8 | 8 | import sys | |
| 9 | 9 | import subprocess | |
| 10 | 10 | import glob | |
| 11 | - from io import StringIO | ||
| 11 | + from io import BytesIO | ||
| 12 | 12 | ||
| 13 | 13 | from stat import S_ISLNK | |
| 14 | 14 | ||
@@ -43,6 +43,7 @@ | |||
| 43 | 43 | izip, | |
| 44 | 44 | xrange, | |
| 45 | 45 | string_types, | |
| 46 | + force_bytes | ||
| 46 | 47 | ) | |
| 47 | 48 | ||
| 48 | 49 | from git.util import ( | |
@@ -562,7 +563,8 @@ def _store_path(self, filepath, fprogress): | |||
| 562 | 563 | st = os.lstat(filepath) # handles non-symlinks as well | |
| 563 | 564 | stream = None | |
| 564 | 565 | if S_ISLNK(st.st_mode): | |
| 565 | - stream = StringIO(os.readlink(filepath)) | ||
| 566 | + # in PY3, readlink is string, but we need bytes. In PY2, it's just OS encoded bytes, we assume UTF-8 | ||
| 567 | + stream = BytesIO(force_bytes(os.readlink(filepath), encoding='utf-8')) | ||
| 566 | 568 | else: | |
| 567 | 569 | stream = open(filepath, 'rb') | |
| 568 | 570 | # END handle stream | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,7 +12,7 @@ | |||
| 12 | 12 | ||
| 13 | 13 | S_IFGITLINK = S_IFLNK | S_IFDIR # a submodule | |
| 14 | 14 | ||
| 15 | - from io import StringIO | ||
| 15 | + from io import BytesIO | ||
| 16 | 16 | ||
| 17 | 17 | from git.util import IndexFileSHA1Writer | |
| 18 | 18 | from git.exc import UnmergedEntriesError | |
@@ -218,7 +218,7 @@ def write_tree_from_cache(entries, odb, sl, si=0): | |||
| 218 | 218 | # END for each entry | |
| 219 | 219 | ||
| 220 | 220 | # finally create the tree | |
| 221 | - sio = StringIO() | ||
| 221 | + sio = BytesIO() | ||
| 222 | 222 | tree_to_stream(tree_items, sio.write) | |
| 223 | 223 | sio.seek(0) | |
| 224 | 224 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,7 +30,7 @@ | |||
| 30 | 30 | altzone | |
| 31 | 31 | ) | |
| 32 | 32 | import os | |
| 33 | - from io import StringIO | ||
| 33 | + from io import BytesIO | ||
| 34 | 34 | import logging | |
| 35 | 35 | ||
| 36 | 36 | log = logging.getLogger('git.objects.commit') | |
@@ -133,7 +133,7 @@ def _set_cache_(self, attr): | |||
| 133 | 133 | if attr in Commit.__slots__: | |
| 134 | 134 | # read the data in a chunk, its faster - then provide a file wrapper | |
| 135 | 135 | binsha, typename, self.size, stream = self.repo.odb.stream(self.binsha) | |
| 136 | - self._deserialize(StringIO(stream.read())) | ||
| 136 | + self._deserialize(BytesIO(stream.read())) | ||
| 137 | 137 | else: | |
| 138 | 138 | super(Commit, self)._set_cache_(attr) | |
| 139 | 139 | # END handle attrs | |
@@ -345,7 +345,7 @@ def create_from_tree(cls, repo, tree, message, parent_commits=None, head=False, | |||
| 345 | 345 | committer, committer_time, committer_offset, | |
| 346 | 346 | message, parent_commits, conf_encoding) | |
| 347 | 347 | ||
| 348 | - stream = StringIO() | ||
| 348 | + stream = BytesIO() | ||
| 349 | 349 | new_commit._serialize(stream) | |
| 350 | 350 | streamlen = stream.tell() | |
| 351 | 351 | stream.seek(0) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,7 +8,7 @@ | |||
| 8 | 8 | find_first_remote_branch | |
| 9 | 9 | ) | |
| 10 | 10 | from git.objects.util import Traversable | |
| 11 | - from io import StringIO # need a dict to set bloody .name field | ||
| 11 | + from io import BytesIO # need a dict to set bloody .name field | ||
| 12 | 12 | from git.util import ( | |
| 13 | 13 | Iterable, | |
| 14 | 14 | join_path_native, | |
@@ -187,8 +187,8 @@ def _clear_cache(self): | |||
| 187 | 187 | ||
| 188 | 188 | @classmethod | |
| 189 | 189 | def _sio_modules(cls, parent_commit): | |
| 190 | - """:return: Configuration file as StringIO - we only access it through the respective blob's data""" | ||
| 191 | - sio = StringIO(parent_commit.tree[cls.k_modules_file].data_stream.read()) | ||
| 190 | + """:return: Configuration file as BytesIO - we only access it through the respective blob's data""" | ||
| 191 | + sio = BytesIO(parent_commit.tree[cls.k_modules_file].data_stream.read()) | ||
| 192 | 192 | sio.name = cls.k_modules_file | |
| 193 | 193 | return sio | |
| 194 | 194 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,7 +1,7 @@ | |||
| 1 | 1 | import git | |
| 2 | 2 | from git.exc import InvalidGitRepositoryError | |
| 3 | 3 | from git.config import GitConfigParser | |
| 4 | - from io import StringIO | ||
| 4 | + from io import BytesIO | ||
| 5 | 5 | import weakref | |
| 6 | 6 | ||
| 7 | 7 | __all__ = ('sm_section', 'sm_name', 'mkhead', 'unbare_repo', 'find_first_remote_branch', | |
@@ -83,7 +83,7 @@ def flush_to_index(self): | |||
| 83 | 83 | """Flush changes in our configuration file to the index""" | |
| 84 | 84 | assert self._smref is not None | |
| 85 | 85 | # should always have a file here | |
| 86 | - assert not isinstance(self._file_or_files, StringIO) | ||
| 86 | + assert not isinstance(self._file_or_files, BytesIO) | ||
| 87 | 87 | ||
| 88 | 88 | sm = self._smref() | |
| 89 | 89 | if sm is not None: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -85,7 +85,7 @@ def from_line(cls, line): | |||
| 85 | 85 | :param line: line without trailing newline | |
| 86 | 86 | :raise ValueError: If line could not be parsed""" | |
| 87 | 87 | try: | |
| 88 | - info, msg = line.split('\t', 2) | ||
| 88 | + info, msg = line.split('\t', 1) | ||
| 89 | 89 | except ValueError: | |
| 90 | 90 | raise ValueError("line is missing tab separator") | |
| 91 | 91 | # END handle first plit | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,3 +1,4 @@ | |||
| 1 | + # just a comment | ||
| 1 | 2 | [alias] | |
| 2 | 3 | st = status | |
| 3 | 4 | ci = commit | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -48,8 +48,8 @@ class StringProcessAdapter(object): | |||
| 48 | 48 | Its tailored to work with the test system only""" | |
| 49 | 49 | ||
| 50 | 50 | def __init__(self, input_string): | |
| 51 | - self.stdout = io.StringIO(input_string) | ||
| 52 | - self.stderr = io.StringIO() | ||
| 51 | + self.stdout = io.BytesIO(input_string) | ||
| 52 | + self.stderr = io.BytesIO() | ||
| 53 | 53 | ||
| 54 | 54 | def wait(self): | |
| 55 | 55 | return 0 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,7 +4,7 @@ | |||
| 4 | 4 | # This module is part of GitPython and is released under | |
| 5 | 5 | # the BSD License: http://www.opensource.org/licenses/bsd-license.php | |
| 6 | 6 | from __future__ import print_function | |
| 7 | - from io import StringIO | ||
| 7 | + from io import BytesIO | ||
| 8 | 8 | from time import time | |
| 9 | 9 | import sys | |
| 10 | 10 | ||
@@ -93,7 +93,7 @@ def test_commit_serialization(self): | |||
| 93 | 93 | hc.committer, hc.committed_date, hc.committer_tz_offset, | |
| 94 | 94 | str(i), parents=hc.parents, encoding=hc.encoding) | |
| 95 | 95 | ||
| 96 | - stream = StringIO() | ||
| 96 | + stream = BytesIO() | ||
| 97 | 97 | cm._serialize(stream) | |
| 98 | 98 | slen = stream.tell() | |
| 99 | 99 | stream.seek(0) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments