From c1181a045915b512ec7d6d2d71d75011766999b2 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Mon, 23 Jun 2014 12:13:10 +0200 Subject: [PATCH] fix except: usage in analysis --- jedi/evaluate/analysis.py | 4 ++++ test/static_analysis/try_except.py | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/jedi/evaluate/analysis.py b/jedi/evaluate/analysis.py index ebbd4b5a..368ef85f 100644 --- a/jedi/evaluate/analysis.py +++ b/jedi/evaluate/analysis.py @@ -90,6 +90,10 @@ def _check_for_exception_catch(evaluator, jedi_obj, exception, payload=None): def check_try_for_except(obj): while obj.next is not None: obj = obj.next + if not obj.inputs: + # No import implies a `except:` catch, which catches + # everything. + return True for i in obj.inputs: except_classes = evaluator.eval_statement(i) for cls in except_classes: diff --git a/test/static_analysis/try_except.py b/test/static_analysis/try_except.py index e7198da0..48c56d53 100644 --- a/test/static_analysis/try_except.py +++ b/test/static_analysis/try_except.py @@ -57,6 +57,15 @@ try: except Undefined: pass +# ----------------- +# inheritance +# ----------------- + +# should catch everything +try: + undefined +except: + pass # ----------------- # kind of similar: hasattr