Skip to content

Commit 99ba753

Browse files
cool-RRByron
authored andcommitted
Fix exception causes in 7 modules
1 parent 4720e63 commit 99ba753

File tree

7 files changed

+31
-29
lines changed

7 files changed

+31
-29
lines changed

‎git/refs/symbolic.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,8 @@ def set_commit(self, commit, logmsg=None):
219219
else:
220220
try:
221221
invalid_type=self.repo.rev_parse(commit).type!=Commit.type
222-
except (BadObject, BadName):
223-
raiseValueError("Invalid object: %s"%commit)
222+
except (BadObject, BadName)ase:
223+
raiseValueError("Invalid object: %s"%commit)frome
224224
# END handle exception
225225
# END verify type
226226

@@ -301,8 +301,8 @@ def set_reference(self, ref, logmsg=None):
301301
try:
302302
obj=self.repo.rev_parse(ref+"^{}") # optionally deref tags
303303
write_value=obj.hexsha
304-
except (BadObject, BadName):
305-
raiseValueError("Could not extract object from %s"%ref)
304+
except (BadObject, BadName)ase:
305+
raiseValueError("Could not extract object from %s"%ref)frome
306306
# END end try string
307307
else:
308308
raiseValueError("Unrecognized Value: %r"%ref)

‎git/remote.py‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ def _from_line(cls, remote, line):
146146
# control character handling
147147
try:
148148
flags|=cls._flag_map[control_character]
149-
exceptKeyError:
150-
raiseValueError("Control character %r unknown as parsed from line %r"% (control_character, line))
149+
exceptKeyErrorase:
150+
raiseValueError("Control character %r unknown as parsed from line %r"% (control_character, line))frome
151151
# END handle control character
152152

153153
# from_to handling
@@ -296,15 +296,15 @@ def _from_line(cls, repo, line, fetch_line):
296296
try:
297297
_new_hex_sha, _fetch_operation, fetch_note=fetch_line.split("\t")
298298
ref_type_name, fetch_note=fetch_note.split(' ', 1)
299-
exceptValueError: # unpack error
300-
raiseValueError("Failed to parse FETCH_HEAD line: %r"%fetch_line)
299+
exceptValueErrorase: # unpack error
300+
raiseValueError("Failed to parse FETCH_HEAD line: %r"%fetch_line)frome
301301

302302
# parse flags from control_character
303303
flags=0
304304
try:
305305
flags|=cls._flag_map[control_character]
306-
exceptKeyError:
307-
raiseValueError("Control character %r unknown as parsed from line %r"% (control_character, line))
306+
exceptKeyErrorase:
307+
raiseValueError("Control character %r unknown as parsed from line %r"% (control_character, line))frome
308308
# END control char exception handling
309309

310310
# parse operation string for more info - makes no sense for symbolic refs, but we parse it anyway

‎git/repo/base.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,8 @@ def submodule(self, name):
341341
:raise ValueError: If no such submodule exists"""
342342
try:
343343
returnself.submodules[name]
344-
exceptIndexError:
345-
raiseValueError("Didn't find submodule named %r"%name)
344+
exceptIndexErrorase:
345+
raiseValueError("Didn't find submodule named %r"%name)frome
346346
# END exception handling
347347

348348
defcreate_submodule(self, *args, **kwargs):

‎git/repo/fun.py‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,16 +251,16 @@ def rev_parse(repo, rev):
251251
try:
252252
# transform reversed index into the format of our revlog
253253
revlog_index=-(int(output_type) +1)
254-
exceptValueError:
254+
exceptValueErrorase:
255255
# TODO: Try to parse the other date options, using parse_date
256256
# maybe
257-
raiseNotImplementedError("Support for additional @{...} modes not implemented")
257+
raiseNotImplementedError("Support for additional @{...} modes not implemented")frome
258258
# END handle revlog index
259259

260260
try:
261261
entry=ref.log_entry(revlog_index)
262-
exceptIndexError:
263-
raiseIndexError("Invalid revlog index: %i"%revlog_index)
262+
exceptIndexErrorase:
263+
raiseIndexError("Invalid revlog index: %i"%revlog_index)frome
264264
# END handle index out of bound
265265

266266
obj=Object.new_from_sha(repo, hex_to_bin(entry.newhexsha))
@@ -324,8 +324,10 @@ def rev_parse(repo, rev):
324324
else:
325325
raiseValueError("Invalid token: %r"%token)
326326
# END end handle tag
327-
except (IndexError, AttributeError):
328-
raiseBadName("Invalid revision spec '%s' - not enough parent commits to reach '%s%i'"% (rev, token, num))
327+
except (IndexError, AttributeError) ase:
328+
raiseBadName(
329+
"Invalid revision spec '%s' - not enough "
330+
"parent commits to reach '%s%i'"% (rev, token, num)) frome
329331
# END exception handling
330332
# END parse loop
331333

‎git/test/test_base.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ def test_add_unicode(self, rw_repo):
129129
# verify first that we could encode file name in this environment
130130
try:
131131
file_path.encode(sys.getfilesystemencoding())
132-
exceptUnicodeEncodeError:
133-
raiseSkipTest("Environment doesn't support unicode filenames")
132+
exceptUnicodeEncodeErrorase:
133+
raiseSkipTest("Environment doesn't support unicode filenames")frome
134134

135135
withopen(file_path, "wb") asfp:
136136
fp.write(b'something')

‎git/test/test_config.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ def test_includes_order(self):
9898
assertr_config.get_value('diff', 'tool') =="meld"
9999
try:
100100
assertr_config.get_value('sec', 'var1') =="value1_main"
101-
exceptAssertionError:
101+
exceptAssertionErrorase:
102102
raiseSkipTest(
103103
'Known failure -- included values are not in effect right away'
104-
)
104+
)frome
105105

106106
@with_rw_directory
107107
deftest_lock_reentry(self, rw_dir):

‎git/util.py‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def onerror(func, path, exc_info):
9494
func(path) # Will scream if still not possible to delete.
9595
exceptExceptionasex:
9696
ifHIDE_WINDOWS_KNOWN_ERRORS:
97-
raiseSkipTest("FIXME: fails with: PermissionError\n{}".format(ex))
97+
raiseSkipTest("FIXME: fails with: PermissionError\n{}".format(ex))fromex
9898
raise
9999

100100
returnshutil.rmtree(path, False, onerror)
@@ -746,7 +746,7 @@ def _obtain_lock_or_raise(self):
746746
fd=os.open(lock_file, flags, 0)
747747
os.close(fd)
748748
exceptOSErrorase:
749-
raiseIOError(str(e))
749+
raiseIOError(str(e))frome
750750

751751
self._owns_lock=True
752752

@@ -801,19 +801,19 @@ def _obtain_lock(self):
801801
whileTrue:
802802
try:
803803
super(BlockingLockFile, self)._obtain_lock()
804-
exceptIOError:
804+
exceptIOErrorase:
805805
# synity check: if the directory leading to the lockfile is not
806806
# readable anymore, raise an exception
807807
curtime=time.time()
808808
ifnotosp.isdir(osp.dirname(self._lock_file_path())):
809809
msg="Directory containing the lockfile %r was not readable anymore after waiting %g seconds"% (
810810
self._lock_file_path(), curtime-starttime)
811-
raiseIOError(msg)
811+
raiseIOError(msg)frome
812812
# END handle missing directory
813813

814814
ifcurtime>=maxtime:
815815
msg="Waited %g seconds for lock at %r"% (maxtime-starttime, self._lock_file_path())
816-
raiseIOError(msg)
816+
raiseIOError(msg)frome
817817
# END abort if we wait too long
818818
time.sleep(self._check_interval)
819819
else:
@@ -878,8 +878,8 @@ def __getitem__(self, index):
878878

879879
try:
880880
returngetattr(self, index)
881-
exceptAttributeError:
882-
raiseIndexError("No item found with id %r"% (self._prefix+index))
881+
exceptAttributeErrorase:
882+
raiseIndexError("No item found with id %r"% (self._prefix+index))frome
883883
# END handle getattr
884884

885885
def__delitem__(self, index):

0 commit comments

Comments
(0)