aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2015-01-04 11:35:16 -0500
committerJason R. Coombs <jaraco@jaraco.com>2015-01-04 11:35:16 -0500
commit9d6a6e5927ae0e67164383e419f3145fc154467e (patch)
tree8872d8b6de4c8706a5178dcb3dab2c9803216e59
parenta849ee957f3ba12945278f88e473eb3612faf4b9 (diff)
downloadexternal_python_setuptools-9d6a6e5927ae0e67164383e419f3145fc154467e.tar.gz
external_python_setuptools-9d6a6e5927ae0e67164383e419f3145fc154467e.tar.bz2
external_python_setuptools-9d6a6e5927ae0e67164383e419f3145fc154467e.zip
Use except/as, now supported by Python 2.6
-rw-r--r--pkg_resources/__init__.py10
-rwxr-xr-xsetuptools/command/easy_install.py12
-rwxr-xr-xsetuptools/command/sdist.py3
-rw-r--r--setuptools/command/upload_docs.py3
-rw-r--r--setuptools/dist.py3
-rw-r--r--setuptools/msvc9_support.py3
-rwxr-xr-xsetuptools/package_index.py15
-rwxr-xr-xsetuptools/sandbox.py3
-rw-r--r--setuptools/tests/test_packageindex.py12
-rw-r--r--setuptools/tests/test_sdist.py12
10 files changed, 27 insertions, 49 deletions
diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py
index f004315a..41d3eb38 100644
--- a/pkg_resources/__init__.py
+++ b/pkg_resources/__init__.py
@@ -843,8 +843,7 @@ class WorkingSet(object):
try:
resolvees = shadow_set.resolve(req, env, installer)
- except ResolutionError:
- v = sys.exc_info()[1]
+ except ResolutionError as v:
# save error info
error_info[dist] = v
if fallback:
@@ -1340,8 +1339,8 @@ class MarkerEvaluation(object):
"""
try:
cls.evaluate_marker(text)
- except SyntaxError:
- return cls.normalize_exception(sys.exc_info()[1])
+ except SyntaxError as e:
+ return cls.normalize_exception(e)
return False
@staticmethod
@@ -1456,8 +1455,7 @@ class MarkerEvaluation(object):
env[new_key] = env.pop(key)
try:
result = _markerlib.interpret(text, env)
- except NameError:
- e = sys.exc_info()[1]
+ except NameError as e:
raise SyntaxError(e.args[0])
return result
diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py
index 1a2f56ae..02ce7636 100755
--- a/setuptools/command/easy_install.py
+++ b/setuptools/command/easy_install.py
@@ -698,13 +698,11 @@ Please make the appropriate changes for your system and try again.
distros = WorkingSet([]).resolve(
[requirement], self.local_index, self.easy_install
)
- except DistributionNotFound:
- e = sys.exc_info()[1]
+ except DistributionNotFound as e:
raise DistutilsError(
"Could not find required distribution %s" % e.args
)
- except VersionConflict:
- e = sys.exc_info()[1]
+ except VersionConflict as e:
raise DistutilsError(
"Installed distribution %s conflicts with requirement %s"
% e.args
@@ -1044,8 +1042,7 @@ See the setuptools documentation for the "develop" command for more info.
)
try:
run_setup(setup_script, args)
- except SystemExit:
- v = sys.exc_info()[1]
+ except SystemExit as v:
raise DistutilsError("Setup script exited with %s" % (v.args[0],))
def build_and_install(self, setup_script, setup_base):
@@ -1889,8 +1886,7 @@ def chmod(path, mode):
log.debug("changing mode of %s to %o", path, mode)
try:
_chmod(path, mode)
- except os.error:
- e = sys.exc_info()[1]
+ except os.error as e:
log.debug("chmod failed: %s", e)
diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py
index 3d33df80..851a1775 100755
--- a/setuptools/command/sdist.py
+++ b/setuptools/command/sdist.py
@@ -70,7 +70,8 @@ class sdist(orig.sdist):
try:
orig.sdist.read_template(self)
except:
- sys.exc_info()[2].tb_next.tb_frame.f_locals['template'].close()
+ _, _, tb = sys.exc_info()
+ tb.tb_next.tb_frame.f_locals['template'].close()
raise
# Beginning with Python 2.7.2, 3.1.4, and 3.2.1, this leaky file handle
diff --git a/setuptools/command/upload_docs.py b/setuptools/command/upload_docs.py
index cd6c300c..001ee936 100644
--- a/setuptools/command/upload_docs.py
+++ b/setuptools/command/upload_docs.py
@@ -169,8 +169,7 @@ class upload_docs(upload):
conn.putheader('Authorization', auth)
conn.endheaders()
conn.send(body)
- except socket.error:
- e = sys.exc_info()[1]
+ except socket.error as e:
self.announce(str(e), log.ERROR)
return
diff --git a/setuptools/dist.py b/setuptools/dist.py
index eb146444..1917a610 100644
--- a/setuptools/dist.py
+++ b/setuptools/dist.py
@@ -131,8 +131,7 @@ def check_entry_points(dist, attr, value):
"""Verify that entry_points map is parseable"""
try:
pkg_resources.EntryPoint.parse_map(value)
- except ValueError:
- e = sys.exc_info()[1]
+ except ValueError as e:
raise DistutilsSetupError(e)
def check_test_suite(dist, attr, value):
diff --git a/setuptools/msvc9_support.py b/setuptools/msvc9_support.py
index d0be70e2..e76d70f0 100644
--- a/setuptools/msvc9_support.py
+++ b/setuptools/msvc9_support.py
@@ -50,8 +50,7 @@ def find_vcvarsall(version):
def query_vcvarsall(version, *args, **kwargs):
try:
return unpatched['query_vcvarsall'](version, *args, **kwargs)
- except distutils.errors.DistutilsPlatformError:
- exc = sys.exc_info()[1]
+ except distutils.errors.DistutilsPlatformError as exc:
if exc and "vcvarsall.bat" in exc.args[0]:
message = 'Microsoft Visual C++ %0.1f is required (%s).' % (version, exc.args[0])
if int(version) == 9:
diff --git a/setuptools/package_index.py b/setuptools/package_index.py
index 58572ce6..5ed19130 100755
--- a/setuptools/package_index.py
+++ b/setuptools/package_index.py
@@ -699,25 +699,21 @@ class PackageIndex(Environment):
return local_open(url)
try:
return open_with_auth(url, self.opener)
- except (ValueError, httplib.InvalidURL):
- v = sys.exc_info()[1]
+ except (ValueError, httplib.InvalidURL) as v:
msg = ' '.join([str(arg) for arg in v.args])
if warning:
self.warn(warning, msg)
else:
raise DistutilsError('%s %s' % (url, msg))
- except urllib2.HTTPError:
- v = sys.exc_info()[1]
+ except urllib2.HTTPError as v:
return v
- except urllib2.URLError:
- v = sys.exc_info()[1]
+ except urllib2.URLError as v:
if warning:
self.warn(warning, v.reason)
else:
raise DistutilsError("Download error for %s: %s"
% (url, v.reason))
- except httplib.BadStatusLine:
- v = sys.exc_info()[1]
+ except httplib.BadStatusLine as v:
if warning:
self.warn(warning, v.line)
else:
@@ -726,8 +722,7 @@ class PackageIndex(Environment):
'down, %s' %
(url, v.line)
)
- except httplib.HTTPException:
- v = sys.exc_info()[1]
+ except httplib.HTTPException as v:
if warning:
self.warn(warning, v)
else:
diff --git a/setuptools/sandbox.py b/setuptools/sandbox.py
index b90d1e1b..7971f42c 100755
--- a/setuptools/sandbox.py
+++ b/setuptools/sandbox.py
@@ -199,8 +199,7 @@ def run_setup(setup_script, args):
ns = dict(__file__=setup_script, __name__='__main__')
_execfile(setup_script, ns)
DirectorySandbox(setup_dir).run(runner)
- except SystemExit:
- v = sys.exc_info()[1]
+ except SystemExit as v:
if v.args and v.args[0]:
raise
# Normal exit, just return
diff --git a/setuptools/tests/test_packageindex.py b/setuptools/tests/test_packageindex.py
index 3e9d1d84..dcd90d6f 100644
--- a/setuptools/tests/test_packageindex.py
+++ b/setuptools/tests/test_packageindex.py
@@ -15,8 +15,7 @@ class TestPackageIndex:
url = 'http://127.0.0.1:0/nonesuch/test_package_index'
try:
v = index.open_url(url)
- except Exception:
- v = sys.exc_info()[1]
+ except Exception as v:
assert url in str(v)
else:
assert isinstance(v, HTTPError)
@@ -32,8 +31,7 @@ class TestPackageIndex:
url = 'url:%20https://svn.plone.org/svn/collective/inquant.contentmirror.plone/trunk'
try:
v = index.open_url(url)
- except Exception:
- v = sys.exc_info()[1]
+ except Exception as v:
assert url in str(v)
else:
assert isinstance(v, HTTPError)
@@ -50,8 +48,7 @@ class TestPackageIndex:
url = 'http://example.com'
try:
v = index.open_url(url)
- except Exception:
- v = sys.exc_info()[1]
+ except Exception as v:
assert 'line' in str(v)
else:
raise AssertionError('Should have raise here!')
@@ -68,8 +65,7 @@ class TestPackageIndex:
url = 'http://http://svn.pythonpaste.org/Paste/wphp/trunk'
try:
index.open_url(url)
- except distutils.errors.DistutilsError:
- error = sys.exc_info()[1]
+ except distutils.errors.DistutilsError as error:
msg = unicode(error)
assert 'nonnumeric port' in msg or 'getaddrinfo failed' in msg or 'Name or service not known' in msg
return
diff --git a/setuptools/tests/test_sdist.py b/setuptools/tests/test_sdist.py
index 943a5dee..68f83ca7 100644
--- a/setuptools/tests/test_sdist.py
+++ b/setuptools/tests/test_sdist.py
@@ -174,8 +174,7 @@ class TestSdistTest:
# The manifest should be UTF-8 encoded
try:
u_contents = contents.decode('UTF-8')
- except UnicodeDecodeError:
- e = sys.exc_info()[1]
+ except UnicodeDecodeError as e:
self.fail(e)
# The manifest should contain the UTF-8 filename
@@ -217,8 +216,7 @@ class TestSdistTest:
# The manifest should be UTF-8 encoded
try:
contents.decode('UTF-8')
- except UnicodeDecodeError:
- e = sys.exc_info()[1]
+ except UnicodeDecodeError as e:
self.fail(e)
# The manifest should contain the UTF-8 filename
@@ -258,8 +256,7 @@ class TestSdistTest:
# The manifest should be UTF-8 encoded
try:
contents.decode('UTF-8')
- except UnicodeDecodeError:
- e = sys.exc_info()[1]
+ except UnicodeDecodeError as e:
self.fail(e)
# The Latin-1 filename should have been skipped
@@ -328,8 +325,7 @@ class TestSdistTest:
with quiet():
try:
cmd.read_manifest()
- except UnicodeDecodeError:
- e = sys.exc_info()[1]
+ except UnicodeDecodeError as e:
self.fail(e)
# The Latin-1 filename should have been skipped