From e60719206392ed47f28ddeadafa8319be90ae0f0 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Thu, 19 Jan 2017 22:19:21 -0500 Subject: A better way to deal with StopEverything exceptions --- coverage/misc.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'coverage/misc.py') diff --git a/coverage/misc.py b/coverage/misc.py index cb9248d2..d3723e29 100644 --- a/coverage/misc.py +++ b/coverage/misc.py @@ -255,8 +255,13 @@ class SimpleRepr(object): ) -class CoverageException(Exception): - """An exception specific to coverage.py.""" +class BaseCoverageException(Exception): + """The base of all Coverage exceptions.""" + pass + + +class CoverageException(BaseCoverageException): + """A run-of-the-mill exception specific to coverage.py.""" pass @@ -298,6 +303,11 @@ class StopEverything(getattr(unittest, 'SkipTest', Exception)): pass -class IncapablePython(CoverageException, StopEverything): - """An operation is attempted that this version of Python cannot do.""" +class IncapablePython(BaseCoverageException, StopEverything): + """An operation is attempted that this version of Python cannot do. + + This is derived from BaseCoverageException, not CoverageException, so that + it won't get caught by 'except CoverageException'. + + """ pass -- cgit v1.2.1