Mercurial > hg
diff hgext/convert/subversion.py @ 25660:328739ea70c3
global: mass rewrite to use modern exception syntax
Python 2.6 introduced the "except type as instance" syntax, replacing
the "except type, instance" syntax that came before. Python 3 dropped
support for the latter syntax. Since we no longer support Python 2.4 or
2.5, we have no need to continue supporting the "except type, instance".
This patch mass rewrites the exception syntax to be Python 2.6+ and
Python 3 compatible.
This patch was produced by running `2to3 -f except -w -n .`.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Tue, 23 Jun 2015 22:20:08 -0700 |
parents | 5c1364b7e5ac |
children | baea47cafe75 |
line wrap: on
line diff
--- a/hgext/convert/subversion.py Tue Jun 23 22:38:21 2015 -0700 +++ b/hgext/convert/subversion.py Tue Jun 23 22:20:08 2015 -0700 @@ -126,7 +126,7 @@ except IOError: # Caller may interrupt the iteration pickle.dump(None, fp, protocol) - except Exception, inst: + except Exception as inst: pickle.dump(str(inst), fp, protocol) else: pickle.dump(None, fp, protocol) @@ -216,7 +216,7 @@ opener = urllib2.build_opener() rsp = opener.open('%s://%s/!svn/ver/0/.svn' % (proto, path)) data = rsp.read() - except urllib2.HTTPError, inst: + except urllib2.HTTPError as inst: if inst.code != 404: # Except for 404 we cannot know for sure this is not an svn repo ui.warn(_('svn: cannot probe remote repository, assume it could ' @@ -944,7 +944,8 @@ firstcset.parents.append(latest) except SvnPathNotFound: pass - except SubversionException, (inst, num): + except SubversionException as xxx_todo_changeme: + (inst, num) = xxx_todo_changeme.args if num == svn.core.SVN_ERR_FS_NO_SUCH_REVISION: raise util.Abort(_('svn: branch has no revision %s') % to_revnum) @@ -970,7 +971,7 @@ info = info[-1] mode = ("svn:executable" in info) and 'x' or '' mode = ("svn:special" in info) and 'l' or mode - except SubversionException, e: + except SubversionException as e: notfound = (svn.core.SVN_ERR_FS_NOT_FOUND, svn.core.SVN_ERR_RA_DAV_PATH_NOT_FOUND) if e.apr_err in notfound: # File not found