From 9348d4bb6cde10aa2da71810dca611c85827bf3c Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Mon, 23 Jun 2014 12:07:51 +0200 Subject: [PATCH] jedi should be able to detect exceptions even in except X: statements --- jedi/evaluate/analysis.py | 6 ++++-- test/static_analysis/try_except.py | 7 +++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/jedi/evaluate/analysis.py b/jedi/evaluate/analysis.py index 401abeac..ebbd4b5a 100644 --- a/jedi/evaluate/analysis.py +++ b/jedi/evaluate/analysis.py @@ -147,8 +147,10 @@ def get_module_statements(module): def add_stmts(stmts): new = set() for stmt in stmts: - if isinstance(stmt, pr.Scope): - new |= add_stmts(stmt.inputs) + if isinstance(stmt, pr.Flow): + while stmt is not None: + new |= add_stmts(stmt.inputs) + stmt = stmt.next continue if isinstance(stmt, pr.KeywordStatement): stmt = stmt.stmt diff --git a/test/static_analysis/try_except.py b/test/static_analysis/try_except.py index 8c419203..e7198da0 100644 --- a/test/static_analysis/try_except.py +++ b/test/static_analysis/try_except.py @@ -50,6 +50,13 @@ try: str.not_existing except [AttributeError]: pass +# Should be able to detect errors in except statement as well. +try: + pass +#! 7 name-error +except Undefined: + pass + # ----------------- # kind of similar: hasattr