Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6aa78cd

Browse files
Harmon758Byron
authored andcommitted
Remove checks for Python 2 and/or 3
1 parente633cc0 commit6aa78cd

File tree

13 files changed

+13
-70
lines changed

13 files changed

+13
-70
lines changed

‎git/cmd.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
string_types,
2525
defenc,
2626
force_bytes,
27-
PY3,
2827
safe_decode,
2928
is_posix,
3029
is_win,
@@ -916,18 +915,12 @@ def transform_kwargs(self, split_single_char_options=True, **kwargs):
916915
@classmethod
917916
def__unpack_args(cls,arg_list):
918917
ifnotisinstance(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-
ifnotPY3andisinstance(arg_list,str):
922-
return [arg_list.encode(defenc)]
923918
return [str(arg_list)]
924919

925920
outlist= []
926921
forarginarg_list:
927922
ifisinstance(arg_list, (list,tuple)):
928923
outlist.extend(cls.__unpack_args(arg))
929-
elifnotPY3andisinstance(arg_list,str):
930-
outlist.append(arg_list.encode(defenc))
931924
# END recursion
932925
else:
933926
outlist.append(str(arg))

‎git/compat.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,5 @@ class metaclass(meta):
7070
def__new__(cls,name,nbases,d):
7171
ifnbasesisNone:
7272
returntype.__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-
ifnotPY3and'___metaclass__'notind:
76-
d['__metaclass__']=meta
7773
returnmeta(name,bases,d)
7874
returnmetaclass(meta.__name__+'Helper',None, {})

‎git/config.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
defenc,
2121
force_text,
2222
with_metaclass,
23-
PY3,
2423
is_win,
2524
)
2625
fromgit.utilimportLockFile
@@ -372,9 +371,7 @@ def string_decode(v):
372371
v=v[:-1]
373372
# end cut trailing escapes to prevent decode error
374373

375-
ifPY3:
376-
returnv.encode(defenc).decode('unicode_escape')
377-
returnv.decode('string_escape')
374+
returnv.encode(defenc).decode('unicode_escape')
378375
# end
379376
# end
380377

‎git/diff.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@
66
importre
77

88
fromgit.cmdimporthandle_process_output
9-
fromgit.compatimport (
10-
defenc,
11-
PY3
12-
)
9+
fromgit.compatimportdefenc
1310
fromgit.utilimportfinalize_process,hex_to_bin
1411

1512
from .objects.blobimportBlob
@@ -27,10 +24,7 @@
2724
def_octal_repl(matchobj):
2825
value=matchobj.group(1)
2926
value=int(value,8)
30-
ifPY3:
31-
value=bytes(bytearray((value,)))
32-
else:
33-
value=chr(value)
27+
value=bytes(bytearray((value,)))
3428
returnvalue
3529

3630

@@ -369,8 +363,6 @@ def __str__(self):
369363
# Python2 silliness: have to assure we convert our likely to be unicode object to a string with the
370364
# right encoding. Otherwise it tries to convert it using ascii, which may fail ungracefully
371365
res=h+msg
372-
ifnotPY3:
373-
res=res.encode(defenc)
374366
# end
375367
returnres
376368

‎git/index/fun.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
fromgit.cmdimportPROC_CREATIONFLAGS,handle_process_output
1717
fromgit.compatimport (
18-
PY3,
1918
defenc,
2019
force_text,
2120
force_bytes,
@@ -73,7 +72,7 @@ def run_commit_hook(name, index, *args):
7372
return
7473

7574
env=os.environ.copy()
76-
env['GIT_INDEX_FILE']=safe_decode(index.path)ifPY3elsesafe_encode(index.path)
75+
env['GIT_INDEX_FILE']=safe_decode(index.path)
7776
env['GIT_EDITOR']=':'
7877
try:
7978
cmd=subprocess.Popen([hp]+list(args),

‎git/objects/tree.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@
1818
tree_to_stream
1919
)
2020

21-
fromgit.compatimportPY3
22-
23-
ifPY3:
24-
cmp=lambdaa,b: (a>b)- (a<b)
21+
cmp=lambdaa,b: (a>b)- (a<b)
2522

2623
__all__= ("TreeModifier","Tree")
2724

‎git/refs/log.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
importtime
33

44
fromgit.compatimport (
5-
PY3,
65
string_types,
76
defenc
87
)
@@ -35,12 +34,7 @@ class RefLogEntry(tuple):
3534

3635
def__repr__(self):
3736
"""Representation of ourselves in git reflog format"""
38-
res=self.format()
39-
ifPY3:
40-
returnres
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-
returnres.encode(defenc)
37+
returnself.format()
4438

4539
defformat(self):
4640
""":return: a string suitable to be placed in a reflog file"""

‎git/repo/base.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
fromgit.compatimport (
1818
text_type,
1919
defenc,
20-
PY3,
2120
safe_decode,
2221
is_win,
2322
)
@@ -691,11 +690,8 @@ def _get_untracked_files(self, *args, **kwargs):
691690
# Special characters are escaped
692691
iffilename[0]==filename[-1]=='"':
693692
filename=filename[1:-1]
694-
ifPY3:
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)
699695
untracked_files.append(filename)
700696
finalize_process(proc)
701697
returnuntracked_files

‎git/test/test_fun.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,6 @@ def test_tree_entries_from_data_with_failing_name_decode_py2(self):
287287
r=tree_entries_from_data(b'100644\x9f\0aaa')
288288
assertr== [('aaa',33188,u'\udc9f')],r
289289

290-
@skipIf(notPY3,'odd types returned ... maybe figure it out one day')
291290
deftest_tree_entries_from_data_with_failing_name_decode_py3(self):
292291
r=tree_entries_from_data(b'100644\x9f\0aaa')
293292
assertr== [(b'aaa',33188,'\udc9f')],r

‎git/test/test_git.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
Repo,
1818
cmd
1919
)
20-
fromgit.compatimportPY3,is_darwin
20+
fromgit.compatimportis_darwin
2121
fromgit.test.libimport (
2222
TestBase,
2323
patch,
@@ -61,18 +61,12 @@ def test_call_process_calls_execute(self, git):
6161

6262
deftest_call_unpack_args_unicode(self):
6363
args=Git._Git__unpack_args(u'Unicode€™')
64-
ifPY3:
65-
mangled_value='Unicode\u20ac\u2122'
66-
else:
67-
mangled_value='Unicode\xe2\x82\xac\xe2\x84\xa2'
64+
mangled_value='Unicode\u20ac\u2122'
6865
assert_equal(args, [mangled_value])
6966

7067
deftest_call_unpack_args(self):
7168
args=Git._Git__unpack_args(['git','log','--',u'Unicode€™'])
72-
ifPY3:
73-
mangled_value='Unicode\u20ac\u2122'
74-
else:
75-
mangled_value='Unicode\xe2\x82\xac\xe2\x84\xa2'
69+
mangled_value='Unicode\u20ac\u2122'
7670
assert_equal(args, ['git','log','--',mangled_value])
7771

7872
@raises(GitCommandError)

‎git/test/test_index.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
GitCommandError,
2626
CheckoutError,
2727
)
28-
fromgit.compatimportstring_types,is_win,PY3
28+
fromgit.compatimportstring_types,is_win
2929
fromgit.excimport (
3030
HookExecutionError,
3131
InvalidGitRepositoryError
@@ -821,10 +821,6 @@ def test_index_bare_add(self, rw_bare_repo):
821821
asserted=True
822822
assertasserted,"Adding using a filename is not correctly asserted."
823823

824-
@skipIf(HIDE_WINDOWS_KNOWN_ERRORSandnotPY3,r"""
825-
FIXME: File "C:\projects\gitpython\git\util.py", line 125, in to_native_path_linux
826-
return path.replace('\\', '/')
827-
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 0: ordinal not in range(128)""")
828824
@with_rw_directory
829825
deftest_add_utf8P_path(self,rw_dir):
830826
# NOTE: fp is not a Unicode object in python 2 (which is the source of the problem)

‎git/test/test_repo.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
GitCommandError
3838
)
3939
fromgit.compatimport (
40-
PY3,
4140
is_win,
4241
string_types,
4342
win_encode,
@@ -526,11 +525,6 @@ def test_untracked_files(self, rwrepo):
526525
num_test_untracked+=join_path_native(base,utfile)infiles
527526
self.assertEqual(len(files),num_test_untracked)
528527

529-
ifis_winandnotPY3andis_invoking_git:
530-
## On Windows, shell needed when passing unicode cmd-args.
531-
#
532-
repo_add=fnt.partial(repo_add,shell=True)
533-
untracked_files= [win_encode(f)forfinuntracked_files]
534528
repo_add(untracked_files)
535529
self.assertEqual(len(rwrepo.untracked_files), (num_recently_untracked-len(files)))
536530
# end for each run

‎git/util.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@
3333

3434
from .compatimport (
3535
MAXSIZE,
36-
defenc,
37-
PY3
36+
defenc
3837
)
3938
from .excimportInvalidGitRepositoryError
4039

@@ -592,9 +591,6 @@ def _main_actor(cls, env_name, env_email, config_reader=None):
592591
('email',env_email,cls.conf_email,default_email)):
593592
try:
594593
val=os.environ[evar]
595-
ifnotPY3:
596-
val=val.decode(defenc)
597-
# end assure we don't get 'invalid strings'
598594
setattr(actor,attr,val)
599595
exceptKeyError:
600596
ifconfig_readerisnotNone:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp