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

Commit d39bd53

Browse files
Remove now unnecessary explicit Unicode string literal prefixes
1 parent ac28616 commit d39bd53

File tree

10 files changed

+69
-69
lines changed

10 files changed

+69
-69
lines changed

‎doc/source/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
master_doc = 'index'
4343

4444
# General information about the project.
45-
project = u'GitPython'
46-
copyright = u'Copyright (C) 2008, 2009 Michael Trier and contributors, 2010-2015 Sebastian Thiel'
45+
project = 'GitPython'
46+
copyright = 'Copyright (C) 2008, 2009 Michael Trier and contributors, 2010-2015 Sebastian Thiel'
4747

4848
# The version info for the project you're documenting, acts as replacement for
4949
# |version| and |release|, also used in various other places throughout the

‎git/exc.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ class CommandError(GitError):
3434

3535
#: A unicode print-format with 2 `%s for `<cmdline>` and the rest,
3636
#: e.g.
37-
#: u"'%s' failed%s"
38-
_msg = u"Cmd('%s') failed%s"
37+
#: "'%s' failed%s"
38+
_msg = "Cmd('%s') failed%s"
3939

4040
def __init__(self, command, status=None, stderr=None, stdout=None):
4141
if not isinstance(command, (tuple, list)):
@@ -44,19 +44,19 @@ def __init__(self, command, status=None, stderr=None, stdout=None):
4444
self.status = status
4545
if status:
4646
if isinstance(status, Exception):
47-
status = u"%s('%s')" % (type(status).__name__, safe_decode(str(status)))
47+
status = "%s('%s')" % (type(status).__name__, safe_decode(str(status)))
4848
else:
4949
try:
50-
status = u'exit code(%s)' % int(status)
50+
status = 'exit code(%s)' % int(status)
5151
except (ValueError, TypeError):
5252
s = safe_decode(str(status))
53-
status = u"'%s'" % s if isinstance(status, str) else s
53+
status = "'%s'" % s if isinstance(status, str) else s
5454

5555
self._cmd = safe_decode(command[0])
56-
self._cmdline = u' '.join(safe_decode(i) for i in command)
57-
self._cause = status and u" due to: %s" % status or "!"
58-
self.stdout = stdout and u"\n stdout: '%s'" % safe_decode(stdout) or ''
59-
self.stderr = stderr and u"\n stderr: '%s'" % safe_decode(stderr) or ''
56+
self._cmdline = ' '.join(safe_decode(i) for i in command)
57+
self._cause = status and " due to: %s" % status or "!"
58+
self.stdout = stdout and "\n stdout: '%s'" % safe_decode(stdout) or ''
59+
self.stderr = stderr and "\n stderr: '%s'" % safe_decode(stderr) or ''
6060

6161
def __str__(self):
6262
return (self._msg + "\n cmdline: %s%s%s") % (
@@ -68,7 +68,7 @@ class GitCommandNotFound(CommandError):
6868
the GIT_PYTHON_GIT_EXECUTABLE environment variable"""
6969
def __init__(self, command, cause):
7070
super(GitCommandNotFound, self).__init__(command, cause)
71-
self._msg = u"Cmd('%s') not found%s"
71+
self._msg = "Cmd('%s') not found%s"
7272

7373

7474
class GitCommandError(CommandError):
@@ -118,7 +118,7 @@ class HookExecutionError(CommandError):
118118

119119
def __init__(self, command, status, stderr=None, stdout=None):
120120
super(HookExecutionError, self).__init__(command, status, stderr, stdout)
121-
self._msg = u"Hook('%s') failed%s"
121+
self._msg = "Hook('%s') failed%s"
122122

123123

124124
class RepositoryDirtyError(GitError):

‎git/refs/log.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ def format(self):
3737
""":return: a string suitable to be placed in a reflog file"""
3838
act = self.actor
3939
time = self.time
40-
return u"{} {} {} <{}> {!s} {}\t{}\n".format(self.oldhexsha,
41-
self.newhexsha,
42-
act.name,
43-
act.email,
44-
time[0],
45-
altz_to_utctz_str(time[1]),
46-
self.message)
40+
return "{} {} {} <{}> {!s} {}\t{}\n".format(self.oldhexsha,
41+
self.newhexsha,
42+
act.name,
43+
act.email,
44+
time[0],
45+
altz_to_utctz_str(time[1]),
46+
self.message)
4747

4848
@property
4949
def oldhexsha(self):

‎git/test/test_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def test_with_rw_remote_and_rw_repo(self, rw_repo, rw_remote_repo):
122122
"Unicode woes, see https://github.com/gitpython-developers/GitPython/pull/519")
123123
@with_rw_repo('0.1.6')
124124
def test_add_unicode(self, rw_repo):
125-
filename = u"שלום.txt"
125+
filename = "שלום.txt"
126126

127127
file_path = osp.join(rw_repo.working_dir, filename)
128128

‎git/test/test_commit.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ def check_entries(d):
132132

133133
def test_unicode_actor(self):
134134
# assure we can parse unicode actors correctly
135-
name = u"Üäöß ÄußÉ"
135+
name = "Üäöß ÄußÉ"
136136
self.assertEqual(len(name), 9)
137-
special = Actor._from_string(u"%s <something@this.com>" % name)
137+
special = Actor._from_string("%s <something@this.com>" % name)
138138
self.assertEqual(special.name, name)
139139
assert isinstance(special.name, str)
140140

@@ -283,10 +283,10 @@ def test_serialization_unicode_support(self):
283283
assert isinstance(cmt.message, str) # it automatically decodes it as such
284284
assert isinstance(cmt.author.name, str) # same here
285285

286-
cmt.message = u"üäêèß"
286+
cmt.message = "üäêèß"
287287
self.assertEqual(len(cmt.message), 5)
288288

289-
cmt.author.name = u"äüß"
289+
cmt.author.name = "äüß"
290290
self.assertEqual(len(cmt.author.name), 3)
291291

292292
cstream = BytesIO()
@@ -308,7 +308,7 @@ def test_invalid_commit(self):
308308
with open(fixture_path('commit_invalid_data'), 'rb') as fd:
309309
cmt._deserialize(fd)
310310

311-
self.assertEqual(cmt.author.name, u'E.Azer Ko�o�o�oculu', cmt.author.name)
311+
self.assertEqual(cmt.author.name, 'E.Azer Ko�o�o�oculu', cmt.author.name)
312312
self.assertEqual(cmt.author.email, 'azer@kodfabrik.com', cmt.author.email)
313313

314314
def test_gpgsig(self):

‎git/test/test_diff.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ def test_diff_with_rename(self):
106106
diff = diffs[0]
107107
self.assertTrue(diff.renamed_file)
108108
self.assertTrue(diff.renamed)
109-
self.assertEqual(diff.rename_from, u'Jérôme')
110-
self.assertEqual(diff.rename_to, u'müller')
109+
self.assertEqual(diff.rename_from, 'Jérôme')
110+
self.assertEqual(diff.rename_to, 'müller')
111111
self.assertEqual(diff.raw_rename_from, b'J\xc3\xa9r\xc3\xb4me')
112112
self.assertEqual(diff.raw_rename_to, b'm\xc3\xbcller')
113113
assert isinstance(str(diff), str)
@@ -133,8 +133,8 @@ def test_diff_with_copied_file(self):
133133

134134
diff = diffs[0]
135135
self.assertTrue(diff.copied_file)
136-
self.assertTrue(diff.a_path, u'test1.txt')
137-
self.assertTrue(diff.b_path, u'test2.txt')
136+
self.assertTrue(diff.a_path, 'test1.txt')
137+
self.assertTrue(diff.b_path, 'test2.txt')
138138
assert isinstance(str(diff), str)
139139

140140
output = StringProcessAdapter(fixture('diff_copied_mode_raw'))
@@ -143,8 +143,8 @@ def test_diff_with_copied_file(self):
143143
diff = diffs[0]
144144
self.assertEqual(diff.change_type, 'C')
145145
self.assertEqual(diff.score, 100)
146-
self.assertEqual(diff.a_path, u'test1.txt')
147-
self.assertEqual(diff.b_path, u'test2.txt')
146+
self.assertEqual(diff.a_path, 'test1.txt')
147+
self.assertEqual(diff.b_path, 'test2.txt')
148148
self.assertEqual(len(list(diffs.iter_change_type('C'))), 1)
149149

150150
def test_diff_with_change_in_type(self):
@@ -237,29 +237,29 @@ def test_diff_unsafe_paths(self):
237237
res = Diff._index_from_patch_format(None, output)
238238

239239
# The "Additions"
240-
self.assertEqual(res[0].b_path, u'path/ starting with a space')
241-
self.assertEqual(res[1].b_path, u'path/"with-quotes"')
242-
self.assertEqual(res[2].b_path, u"path/'with-single-quotes'")
243-
self.assertEqual(res[3].b_path, u'path/ending in a space ')
244-
self.assertEqual(res[4].b_path, u'path/with\ttab')
245-
self.assertEqual(res[5].b_path, u'path/with\nnewline')
246-
self.assertEqual(res[6].b_path, u'path/with spaces')
247-
self.assertEqual(res[7].b_path, u'path/with-question-mark?')
248-
self.assertEqual(res[8].b_path, u'path/ ̄\\_(ツ)_| ̄')
249-
self.assertEqual(res[9].b_path, u'path/💩.txt')
240+
self.assertEqual(res[0].b_path, 'path/ starting with a space')
241+
self.assertEqual(res[1].b_path, 'path/"with-quotes"')
242+
self.assertEqual(res[2].b_path, "path/'with-single-quotes'")
243+
self.assertEqual(res[3].b_path, 'path/ending in a space ')
244+
self.assertEqual(res[4].b_path, 'path/with\ttab')
245+
self.assertEqual(res[5].b_path, 'path/with\nnewline')
246+
self.assertEqual(res[6].b_path, 'path/with spaces')
247+
self.assertEqual(res[7].b_path, 'path/with-question-mark?')
248+
self.assertEqual(res[8].b_path, 'path/ ̄\\_(ツ)_| ̄')
249+
self.assertEqual(res[9].b_path, 'path/💩.txt')
250250
self.assertEqual(res[9].b_rawpath, b'path/\xf0\x9f\x92\xa9.txt')
251-
self.assertEqual(res[10].b_path, u'path/�-invalid-unicode-path.txt')
251+
self.assertEqual(res[10].b_path, 'path/�-invalid-unicode-path.txt')
252252
self.assertEqual(res[10].b_rawpath, b'path/\x80-invalid-unicode-path.txt')
253253

254254
# The "Moves"
255255
# NOTE: The path prefixes a/ and b/ here are legit! We're actually
256256
# verifying that it's not "a/a/" that shows up, see the fixture data.
257-
self.assertEqual(res[11].a_path, u'a/with spaces') # NOTE: path a/ here legit!
258-
self.assertEqual(res[11].b_path, u'b/with some spaces') # NOTE: path b/ here legit!
259-
self.assertEqual(res[12].a_path, u'a/ending in a space ')
260-
self.assertEqual(res[12].b_path, u'b/ending with space ')
261-
self.assertEqual(res[13].a_path, u'a/"with-quotes"')
262-
self.assertEqual(res[13].b_path, u'b/"with even more quotes"')
257+
self.assertEqual(res[11].a_path, 'a/with spaces') # NOTE: path a/ here legit!
258+
self.assertEqual(res[11].b_path, 'b/with some spaces') # NOTE: path b/ here legit!
259+
self.assertEqual(res[12].a_path, 'a/ending in a space ')
260+
self.assertEqual(res[12].b_path, 'b/ending with space ')
261+
self.assertEqual(res[13].a_path, 'a/"with-quotes"')
262+
self.assertEqual(res[13].b_path, 'b/"with even more quotes"')
263263

264264
def test_diff_patch_format(self):
265265
# test all of the 'old' format diffs for completness - it should at least
@@ -277,7 +277,7 @@ def test_diff_with_spaces(self):
277277
data = StringProcessAdapter(fixture('diff_file_with_spaces'))
278278
diff_index = Diff._index_from_patch_format(self.rorepo, data)
279279
self.assertIsNone(diff_index[0].a_path, repr(diff_index[0].a_path))
280-
self.assertEqual(diff_index[0].b_path, u'file with spaces', repr(diff_index[0].b_path))
280+
self.assertEqual(diff_index[0].b_path, 'file with spaces', repr(diff_index[0].b_path))
281281

282282
def test_diff_submodule(self):
283283
"""Test that diff is able to correctly diff commits that cover submodule changes"""

‎git/test/test_git.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ def test_call_process_calls_execute(self, git):
5050
self.assertEqual(git.call_args, ((['git', 'version'],), {}))
5151

5252
def test_call_unpack_args_unicode(self):
53-
args = Git._Git__unpack_args(u'Unicode€TM')
53+
args = Git._Git__unpack_args('Unicode€TM')
5454
mangled_value = 'Unicode\u20ac\u2122'
5555
self.assertEqual(args, [mangled_value])
5656

5757
def test_call_unpack_args(self):
58-
args = Git._Git__unpack_args(['git', 'log', '--', u'Unicode€TM'])
58+
args = Git._Git__unpack_args(['git', 'log', '--', 'Unicode€TM'])
5959
mangled_value = 'Unicode\u20ac\u2122'
6060
self.assertEqual(args, ['git', 'log', '--', mangled_value])
6161

‎git/test/test_index.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ def test_index_mutation(self, rw_repo):
429429
num_entries = len(index.entries)
430430
cur_head = rw_repo.head
431431

432-
uname = u"Thomas Müller"
432+
uname = "Thomas Müller"
433433
umail = "sd@company.com"
434434
with rw_repo.config_writer() as writer:
435435
writer.set_value("user", "name", uname)
@@ -484,7 +484,7 @@ def mixed_iterator():
484484
# TEST COMMITTING
485485
# commit changed index
486486
cur_commit = cur_head.commit
487-
commit_message = u"commit default head by Frèderic Çaufl€"
487+
commit_message = "commit default head by Frèderic Çaufl€"
488488

489489
new_commit = index.commit(commit_message, head=False)
490490
assert cur_commit != new_commit
@@ -500,13 +500,13 @@ def mixed_iterator():
500500
# commit with other actor
501501
cur_commit = cur_head.commit
502502

503-
my_author = Actor(u"Frèderic Çaufl€", "author@example.com")
504-
my_committer = Actor(u"Committing Frèderic Çaufl€", "committer@example.com")
503+
my_author = Actor("Frèderic Çaufl€", "author@example.com")
504+
my_committer = Actor("Committing Frèderic Çaufl€", "committer@example.com")
505505
commit_actor = index.commit(commit_message, author=my_author, committer=my_committer)
506506
assert cur_commit != commit_actor
507-
self.assertEqual(commit_actor.author.name, u"Frèderic Çaufl€")
507+
self.assertEqual(commit_actor.author.name, "Frèderic Çaufl€")
508508
self.assertEqual(commit_actor.author.email, "author@example.com")
509-
self.assertEqual(commit_actor.committer.name, u"Committing Frèderic Çaufl€")
509+
self.assertEqual(commit_actor.committer.name, "Committing Frèderic Çaufl€")
510510
self.assertEqual(commit_actor.committer.email, "committer@example.com")
511511
self.assertEqual(commit_actor.message, commit_message)
512512
self.assertEqual(commit_actor.parents[0], cur_commit)
@@ -516,7 +516,7 @@ def mixed_iterator():
516516

517517
# commit with author_date and commit_date
518518
cur_commit = cur_head.commit
519-
commit_message = u"commit with dates by Avinash Sajjanshetty"
519+
commit_message = "commit with dates by Avinash Sajjanshetty"
520520

521521
new_commit = index.commit(commit_message, author_date="2006年04月07日T22:13:13", commit_date="2005年04月07日T22:13:13")
522522
assert cur_commit != new_commit
@@ -777,7 +777,7 @@ def test_compare_write_tree(self, rw_repo):
777777
def test_index_single_addremove(self, rw_repo):
778778
fp = osp.join(rw_repo.working_dir, 'testfile.txt')
779779
with open(fp, 'w') as fs:
780-
fs.write(u'content of testfile')
780+
fs.write('content of testfile')
781781
self._assert_entries(rw_repo.index.add(fp))
782782
deleted_files = rw_repo.index.remove(fp)
783783
assert deleted_files
@@ -826,7 +826,7 @@ def test_add_utf8P_path(self, rw_dir):
826826
# NOTE: fp is not a Unicode object in python 2 (which is the source of the problem)
827827
fp = osp.join(rw_dir, 'ø.txt')
828828
with open(fp, 'wb') as fs:
829-
fs.write(u'content of ø'.encode('utf-8'))
829+
fs.write('content of ø'.encode('utf-8'))
830830

831831
r = Repo.init(rw_dir)
832832
r.index.add([fp])
@@ -896,16 +896,16 @@ def test_pre_commit_hook_fail(self, rw_repo):
896896

897897
@with_rw_repo('HEAD', bare=True)
898898
def test_commit_msg_hook_success(self, rw_repo):
899-
commit_message = u"commit default head by Frèderic Çaufl€"
900-
from_hook_message = u"from commit-msg"
899+
commit_message = "commit default head by Frèderic Çaufl€"
900+
from_hook_message = "from commit-msg"
901901
index = rw_repo.index
902902
_make_hook(
903903
index.repo.git_dir,
904904
'commit-msg',
905905
'printf " {}" >> "1ドル"'.format(from_hook_message)
906906
)
907907
new_commit = index.commit(commit_message)
908-
self.assertEqual(new_commit.message, u"{} {}".format(commit_message, from_hook_message))
908+
self.assertEqual(new_commit.message, "{} {}".format(commit_message, from_hook_message))
909909

910910
@with_rw_repo('HEAD', bare=True)
911911
def test_commit_msg_hook_fail(self, rw_repo):

‎git/test/test_repo.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ def test_blame_incremental(self, git):
453453
self.assertEqual(commits, ['82b8902', '82b8902', 'c76852d', 'c76852d', 'c76852d'])
454454

455455
# Original filenames
456-
self.assertSequenceEqual([entry.orig_path for entry in blame_output], [u'AUTHORS'] * len(blame_output))
456+
self.assertSequenceEqual([entry.orig_path for entry in blame_output], ['AUTHORS'] * len(blame_output))
457457

458458
# Original line numbers
459459
orig_ranges = flatten([entry.orig_linenos for entry in blame_output])
@@ -478,10 +478,10 @@ def test_blame_complex_revision(self, git):
478478
def test_untracked_files(self, rwrepo):
479479
for run, repo_add in enumerate((rwrepo.index.add, rwrepo.git.add)):
480480
base = rwrepo.working_tree_dir
481-
files = (join_path_native(base, u"%i_test _myfile" % run),
481+
files = (join_path_native(base, "%i_test _myfile" % run),
482482
join_path_native(base, "%i_test_other_file" % run),
483-
join_path_native(base, u"%i__çava verböten" % run),
484-
join_path_native(base, u"%i_çava-----verböten" % run))
483+
join_path_native(base, "%i__çava verböten" % run),
484+
join_path_native(base, "%i_çava-----verböten" % run))
485485

486486
num_recently_untracked = 0
487487
for fpath in files:

‎git/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ def __str__(self):
555555
return self.name
556556

557557
def __repr__(self):
558-
return u'<git.Actor "%s <%s>">' % (self.name, self.email)
558+
return '<git.Actor "%s <%s>">' % (self.name, self.email)
559559

560560
@classmethod
561561
def _from_string(cls, string):

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /