Convert except X, T to except X as T

This commit is contained in:
JoeLametta
2018-05-02 08:10:00 +00:00
parent 5f75d41c7b
commit 4280dbfafc
12 changed files with 31 additions and 31 deletions

View File

@@ -156,7 +156,7 @@ def _save_entry(raw_entry, path):
# XXX: os.makedirs(exist_ok=True) in py3
try:
makedirs(dirname(path))
except OSError, e:
except OSError as e:
if e.errno != EEXIST:
logger.error('could not save entry to %s: %r' % (path, str(e)))
return

View File

@@ -127,7 +127,7 @@ class PersistedCache:
self.path = path
try:
os.makedirs(self.path)
except OSError, e:
except OSError as e:
if e.errno != 17: # FIXME
raise

View File

@@ -298,7 +298,7 @@ class VersionGetter(object):
vre = self._regexp.search(output)
if vre:
version = self._expander % vre.groupdict()
except OSError, e:
except OSError as e:
import errno
if e.errno == errno.ENOENT:
raise MissingDependencyException(self._dep)

View File

@@ -277,7 +277,7 @@ def musicbrainz(discid, country=None, record=False):
try:
result = musicbrainzngs.get_releases_by_discid(
discid, includes=["artists", "recordings", "release-groups"])
except musicbrainzngs.ResponseError, e:
except musicbrainzngs.ResponseError as e:
if isinstance(e.cause, urllib2.HTTPError):
if e.cause.code == 404:
raise NotFoundException(e)

View File

@@ -252,7 +252,7 @@ class Program:
if code == 200:
return md['title']
except IOError, e:
except IOError as e:
# FIXME: for some reason errno is a str ?
if e.errno == 'socket error':
self._stdout.write("Warning: network error: %r\n" % (e, ))
@@ -283,13 +283,13 @@ class Program:
country=country,
record=self._record)
break
except mbngs.NotFoundException, e:
except mbngs.NotFoundException as e:
logger.warning("release not found: %r" % (e, ))
break
except musicbrainzngs.NetworkError, e:
except musicbrainzngs.NetworkError as e:
logger.warning("network error: %r" % (e, ))
break
except mbngs.MusicBrainzException, e:
except mbngs.MusicBrainzException as e:
logger.warning("musicbrainz exception: %r" % (e, ))
time.sleep(5)
continue
@@ -424,7 +424,7 @@ class Program:
title = track.title
mbidTrack = track.mbid
mbidTrackArtist = track.mbidArtist
except IndexError, e:
except IndexError as e:
print('ERROR: no track %d found, %r' % (number, e))
raise
else:
@@ -478,7 +478,7 @@ class Program:
try:
runner.run(t)
except task.TaskException, e:
except task.TaskException as e:
if isinstance(e.exception, common.MissingFrames):
logger.warning('missing frames for %r' % trackResult.filename)
return False

View File

@@ -44,7 +44,7 @@ class PopenTask(task.Task):
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
close_fds=True, cwd=self.cwd)
except OSError, e:
except OSError as e:
import errno
if e.errno == errno.ENOENT:
self.commandMissing()
@@ -88,7 +88,7 @@ class PopenTask(task.Task):
return
self._done()
except Exception, e:
except Exception as e:
logger.debug('exception during _read(): %r', str(e))
self.setException(e)
self.stop()