diff --git a/CHANGES.rst b/CHANGES.rst index 3b2bf3a4c..21f8a3b6d 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -2,6 +2,39 @@ CHANGES ======= +---------- +0.8.6-dev0 +---------- + +* Bug fix: Honor installed sys.excepthook in pex teardown. + `RB #1733 `_ + +----- +0.8.5 +----- + +* Bug fix: Fixup string formatting in pex/bin/pex.py to support Python 2.6 + `Pull Request #40 `_ + +----- +0.8.4 +----- + +* Performance improvement: Speed up the best-case scenario of dependency resolution. + `RB #1685 `_ + +* Bug fix: Change from uuid4().get_hex() to uuid4().hex to maintain Python3 + compatibility of pex.common. + `Pull Request #39 `_ + +* Bug fix: Actually cache the results of translation. Previously bdist translations + would be created in a temporary directory even if a cache location was specified. + `RB #1666 `_ + +* Bug fix: Support all potential abi tag permutations when determining platform + compatibility. + `Pull Request #33 `_ + ----- 0.8.3 ----- diff --git a/pex/pex.py b/pex/pex.py index beec14277..139343628 100644 --- a/pex/pex.py +++ b/pex/pex.py @@ -6,7 +6,6 @@ import os import subprocess import sys -import traceback from contextlib import contextmanager from distutils import sysconfig from site import USER_SITE @@ -273,15 +272,16 @@ def execute(self, args=()): else: self.execute_interpreter() except Exception: - # Catch and print any exceptions before we tear things down in finally, then - # reraise so that the exit status is reflected correctly. - traceback.print_exc() + # Allow the current sys.excepthook to handle this app exception before we tear things down in + # finally, then reraise so that the exit status is reflected correctly. + sys.excepthook(*sys.exc_info()) raise finally: # squash all exceptions on interpreter teardown -- the primary type here are # atexit handlers failing to run because of things such as: # http://stackoverflow.com/questions/2572172/referencing-other-modules-in-atexit if 'PEX_TEARDOWN_VERBOSE' not in os.environ: + sys.stderr.flush() sys.stderr = DevNull() sys.excepthook = lambda *a, **kw: None diff --git a/pex/version.py b/pex/version.py index 73f831511..95b4da687 100644 --- a/pex/version.py +++ b/pex/version.py @@ -1 +1 @@ -__version__ = '0.8.5' +__version__ = '0.8.6-dev0' diff --git a/tests/test_pex.py b/tests/test_pex.py index ff48cfe82..b1a5692e3 100644 --- a/tests/test_pex.py +++ b/tests/test_pex.py @@ -19,6 +19,24 @@ def test_pex_uncaught_exceptions(): assert rc == 1 +def test_excepthook_honored(): + body = textwrap.dedent(""" + import sys + + def excepthook(ex_type, ex, tb): + print('Custom hook called with: {0}'.format(ex)) + sys.exit(42) + + sys.excepthook = excepthook + + raise Exception('This is an exception') + """) + + so, rc = run_simple_pex_test(body) + assert so == b'Custom hook called with: This is an exception\n', 'Standard out was: %s' % so + assert rc == 42 + + def test_pex_sys_exit_does_not_raise(): body = "import sys; sys.exit(2)" so, rc = run_simple_pex_test(body)