# HG changeset patch # User Matt Mackall # Date 1431702046 18000 # Node ID c6427cd45760eb106966106a45083180d59ea9e4 # Parent 754df8e932d3cb317f6804008344ce2dca5192e6 setup: use try/except/finally This will raise a syntax error for people who attempt to use Py2.4, but that's already going to fail and we have no way to keep other 2.6isms from creeping in since we've removed the check-code rules and the buildbot. diff -r 754df8e932d3 -r c6427cd45760 setup.py --- a/setup.py Fri May 15 09:58:21 2015 -0500 +++ b/setup.py Fri May 15 10:00:46 2015 -0500 @@ -106,25 +106,24 @@ tmpdir = tempfile.mkdtemp(prefix='hg-install-') devnull = oldstderr = None try: - try: - fname = os.path.join(tmpdir, 'funcname.c') - f = open(fname, 'w') - f.write('int main(void) {\n') - f.write(' %s();\n' % funcname) - f.write('}\n') - f.close() - # Redirect stderr to /dev/null to hide any error messages - # from the compiler. - # This will have to be changed if we ever have to check - # for a function on Windows. - devnull = open('/dev/null', 'w') - oldstderr = os.dup(sys.stderr.fileno()) - os.dup2(devnull.fileno(), sys.stderr.fileno()) - objects = cc.compile([fname], output_dir=tmpdir) - cc.link_executable(objects, os.path.join(tmpdir, "a.out")) - except Exception: - return False + fname = os.path.join(tmpdir, 'funcname.c') + f = open(fname, 'w') + f.write('int main(void) {\n') + f.write(' %s();\n' % funcname) + f.write('}\n') + f.close() + # Redirect stderr to /dev/null to hide any error messages + # from the compiler. + # This will have to be changed if we ever have to check + # for a function on Windows. + devnull = open('/dev/null', 'w') + oldstderr = os.dup(sys.stderr.fileno()) + os.dup2(devnull.fileno(), sys.stderr.fileno()) + objects = cc.compile([fname], output_dir=tmpdir) + cc.link_executable(objects, os.path.join(tmpdir, "a.out")) return True + except Exception: + return False finally: if oldstderr is not None: os.dup2(oldstderr, sys.stderr.fileno())