| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e633cc0 commit 6aa78cd
13 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,7 +24,6 @@ | |||
| 24 | 24 | string_types, | |
| 25 | 25 | defenc, | |
| 26 | 26 | force_bytes, | |
| 27 | - PY3, | ||
| 28 | 27 | safe_decode, | |
| 29 | 28 | is_posix, | |
| 30 | 29 | is_win, | |
@@ -916,18 +915,12 @@ def transform_kwargs(self, split_single_char_options=True, **kwargs): | |||
| 916 | 915 | @classmethod | |
| 917 | 916 | def __unpack_args(cls, arg_list): | |
| 918 | 917 | if not isinstance(arg_list, (list, tuple)): | |
| 919 | - # This is just required for unicode conversion, as subprocess can't handle it | ||
| 920 | - # However, in any other case, passing strings (usually utf-8 encoded) is totally fine | ||
| 921 | - if not PY3 and isinstance(arg_list, str): | ||
| 922 | - return [arg_list.encode(defenc)] | ||
| 923 | 918 | return [str(arg_list)] | |
| 924 | 919 | ||
| 925 | 920 | outlist = [] | |
| 926 | 921 | for arg in arg_list: | |
| 927 | 922 | if isinstance(arg_list, (list, tuple)): | |
| 928 | 923 | outlist.extend(cls.__unpack_args(arg)) | |
| 929 | - elif not PY3 and isinstance(arg_list, str): | ||
| 930 | - outlist.append(arg_list.encode(defenc)) | ||
| 931 | 924 | # END recursion | |
| 932 | 925 | else: | |
| 933 | 926 | outlist.append(str(arg)) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -70,9 +70,5 @@ class metaclass(meta): | |||
| 70 | 70 | def __new__(cls, name, nbases, d): | |
| 71 | 71 | if nbases is None: | |
| 72 | 72 | return type.__new__(cls, name, (), d) | |
| 73 | - # There may be clients who rely on this attribute to be set to a reasonable value, which is why | ||
| 74 | - # we set the __metaclass__ attribute explicitly | ||
| 75 | - if not PY3 and '___metaclass__' not in d: | ||
| 76 | - d['__metaclass__'] = meta | ||
| 77 | 73 | return meta(name, bases, d) | |
| 78 | 74 | return metaclass(meta.__name__ + 'Helper', None, {}) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,7 +20,6 @@ | |||
| 20 | 20 | defenc, | |
| 21 | 21 | force_text, | |
| 22 | 22 | with_metaclass, | |
| 23 | - PY3, | ||
| 24 | 23 | is_win, | |
| 25 | 24 | ) | |
| 26 | 25 | from git.util import LockFile | |
@@ -372,9 +371,7 @@ def string_decode(v): | |||
| 372 | 371 | v = v[:-1] | |
| 373 | 372 | # end cut trailing escapes to prevent decode error | |
| 374 | 373 | ||
| 375 | - if PY3: | ||
| 376 | - return v.encode(defenc).decode('unicode_escape') | ||
| 377 | - return v.decode('string_escape') | ||
| 374 | + return v.encode(defenc).decode('unicode_escape') | ||
| 378 | 375 | # end | |
| 379 | 376 | # end | |
| 380 | 377 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,10 +6,7 @@ | |||
| 6 | 6 | import re | |
| 7 | 7 | ||
| 8 | 8 | from git.cmd import handle_process_output | |
| 9 | - from git.compat import ( | ||
| 10 | - defenc, | ||
| 11 | - PY3 | ||
| 12 | - ) | ||
| 9 | + from git.compat import defenc | ||
| 13 | 10 | from git.util import finalize_process, hex_to_bin | |
| 14 | 11 | ||
| 15 | 12 | from .objects.blob import Blob | |
@@ -27,10 +24,7 @@ | |||
| 27 | 24 | def _octal_repl(matchobj): | |
| 28 | 25 | value = matchobj.group(1) | |
| 29 | 26 | value = int(value, 8) | |
| 30 | - if PY3: | ||
| 31 | - value = bytes(bytearray((value,))) | ||
| 32 | - else: | ||
| 33 | - value = chr(value) | ||
| 27 | + value = bytes(bytearray((value,))) | ||
| 34 | 28 | return value | |
| 35 | 29 | ||
| 36 | 30 | ||
@@ -369,8 +363,6 @@ def __str__(self): | |||
| 369 | 363 | # Python2 silliness: have to assure we convert our likely to be unicode object to a string with the | |
| 370 | 364 | # right encoding. Otherwise it tries to convert it using ascii, which may fail ungracefully | |
| 371 | 365 | res = h + msg | |
| 372 | - if not PY3: | ||
| 373 | - res = res.encode(defenc) | ||
| 374 | 366 | # end | |
| 375 | 367 | return res | |
| 376 | 368 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,7 +15,6 @@ | |||
| 15 | 15 | ||
| 16 | 16 | from git.cmd import PROC_CREATIONFLAGS, handle_process_output | |
| 17 | 17 | from git.compat import ( | |
| 18 | - PY3, | ||
| 19 | 18 | defenc, | |
| 20 | 19 | force_text, | |
| 21 | 20 | force_bytes, | |
@@ -73,7 +72,7 @@ def run_commit_hook(name, index, *args): | |||
| 73 | 72 | return | |
| 74 | 73 | ||
| 75 | 74 | env = os.environ.copy() | |
| 76 | - env['GIT_INDEX_FILE'] = safe_decode(index.path) if PY3 else safe_encode(index.path) | ||
| 75 | + env['GIT_INDEX_FILE'] = safe_decode(index.path) | ||
| 77 | 76 | env['GIT_EDITOR'] = ':' | |
| 78 | 77 | try: | |
| 79 | 78 | cmd = subprocess.Popen([hp] + list(args), | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,10 +18,7 @@ | |||
| 18 | 18 | tree_to_stream | |
| 19 | 19 | ) | |
| 20 | 20 | ||
| 21 | - from git.compat import PY3 | ||
| 22 | - | ||
| 23 | - if PY3: | ||
| 24 | - cmp = lambda a, b: (a > b) - (a < b) | ||
| 21 | + cmp = lambda a, b: (a > b) - (a < b) | ||
| 25 | 22 | ||
| 26 | 23 | __all__ = ("TreeModifier", "Tree") | |
| 27 | 24 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,7 +2,6 @@ | |||
| 2 | 2 | import time | |
| 3 | 3 | ||
| 4 | 4 | from git.compat import ( | |
| 5 | - PY3, | ||
| 6 | 5 | string_types, | |
| 7 | 6 | defenc | |
| 8 | 7 | ) | |
@@ -35,12 +34,7 @@ class RefLogEntry(tuple): | |||
| 35 | 34 | ||
| 36 | 35 | def __repr__(self): | |
| 37 | 36 | """Representation of ourselves in git reflog format""" | |
| 38 | - res = self.format() | ||
| 39 | - if PY3: | ||
| 40 | - return res | ||
| 41 | - # repr must return a string, which it will auto-encode from unicode using the default encoding. | ||
| 42 | - # This usually fails, so we encode ourselves | ||
| 43 | - return res.encode(defenc) | ||
| 37 | + return self.format() | ||
| 44 | 38 | ||
| 45 | 39 | def format(self): | |
| 46 | 40 | """:return: a string suitable to be placed in a reflog file""" | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,7 +17,6 @@ | |||
| 17 | 17 | from git.compat import ( | |
| 18 | 18 | text_type, | |
| 19 | 19 | defenc, | |
| 20 | - PY3, | ||
| 21 | 20 | safe_decode, | |
| 22 | 21 | is_win, | |
| 23 | 22 | ) | |
@@ -691,11 +690,8 @@ def _get_untracked_files(self, *args, **kwargs): | |||
| 691 | 690 | # Special characters are escaped | |
| 692 | 691 | if filename[0] == filename[-1] == '"': | |
| 693 | 692 | filename = filename[1:-1] | |
| 694 | - if PY3: | ||
| 695 | - # WHATEVER ... it's a mess, but works for me | ||
| 696 | - filename = filename.encode('ascii').decode('unicode_escape').encode('latin1').decode(defenc) | ||
| 697 | - else: | ||
| 698 | - filename = filename.decode('string_escape').decode(defenc) | ||
| 693 | + # WHATEVER ... it's a mess, but works for me | ||
| 694 | + filename = filename.encode('ascii').decode('unicode_escape').encode('latin1').decode(defenc) | ||
| 699 | 695 | untracked_files.append(filename) | |
| 700 | 696 | finalize_process(proc) | |
| 701 | 697 | return untracked_files | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -287,7 +287,6 @@ def test_tree_entries_from_data_with_failing_name_decode_py2(self): | |||
| 287 | 287 | r = tree_entries_from_data(b'100644 \x9f\0aaa') | |
| 288 | 288 | assert r == [('aaa', 33188, u'\udc9f')], r | |
| 289 | 289 | ||
| 290 | - @skipIf(not PY3, 'odd types returned ... maybe figure it out one day') | ||
| 291 | 290 | def test_tree_entries_from_data_with_failing_name_decode_py3(self): | |
| 292 | 291 | r = tree_entries_from_data(b'100644 \x9f\0aaa') | |
| 293 | 292 | assert r == [(b'aaa', 33188, '\udc9f')], r | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,7 +17,7 @@ | |||
| 17 | 17 | Repo, | |
| 18 | 18 | cmd | |
| 19 | 19 | ) | |
| 20 | - from git.compat import PY3, is_darwin | ||
| 20 | + from git.compat import is_darwin | ||
| 21 | 21 | from git.test.lib import ( | |
| 22 | 22 | TestBase, | |
| 23 | 23 | patch, | |
@@ -61,18 +61,12 @@ def test_call_process_calls_execute(self, git): | |||
| 61 | 61 | ||
| 62 | 62 | def test_call_unpack_args_unicode(self): | |
| 63 | 63 | args = Git._Git__unpack_args(u'Unicode€™') | |
| 64 | - if PY3: | ||
| 65 | - mangled_value = 'Unicode\u20ac\u2122' | ||
| 66 | - else: | ||
| 67 | - mangled_value = 'Unicode\xe2\x82\xac\xe2\x84\xa2' | ||
| 64 | + mangled_value = 'Unicode\u20ac\u2122' | ||
| 68 | 65 | assert_equal(args, [mangled_value]) | |
| 69 | 66 | ||
| 70 | 67 | def test_call_unpack_args(self): | |
| 71 | 68 | args = Git._Git__unpack_args(['git', 'log', '--', u'Unicode€™']) | |
| 72 | - if PY3: | ||
| 73 | - mangled_value = 'Unicode\u20ac\u2122' | ||
| 74 | - else: | ||
| 75 | - mangled_value = 'Unicode\xe2\x82\xac\xe2\x84\xa2' | ||
| 69 | + mangled_value = 'Unicode\u20ac\u2122' | ||
| 76 | 70 | assert_equal(args, ['git', 'log', '--', mangled_value]) | |
| 77 | 71 | ||
| 78 | 72 | @raises(GitCommandError) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments