mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 06:24:27 +08:00
fixed inheritance for exception checks
This commit is contained in:
@@ -85,7 +85,10 @@ def add(evaluator, name, jedi_obj, message=None, typ=Error, payload=None):
|
|||||||
def _check_for_exception_catch(evaluator, jedi_obj, exception, payload=None):
|
def _check_for_exception_catch(evaluator, jedi_obj, exception, payload=None):
|
||||||
"""Returns True if the exception was catched."""
|
"""Returns True if the exception was catched."""
|
||||||
def check_match(cls):
|
def check_match(cls):
|
||||||
return isinstance(cls, CompiledObject) and cls.obj == exception
|
try:
|
||||||
|
return isinstance(cls, CompiledObject) and issubclass(exception, cls.obj)
|
||||||
|
except TypeError:
|
||||||
|
return False
|
||||||
|
|
||||||
def check_try_for_except(obj):
|
def check_try_for_except(obj):
|
||||||
while obj.next is not None:
|
while obj.next is not None:
|
||||||
@@ -94,6 +97,7 @@ def _check_for_exception_catch(evaluator, jedi_obj, exception, payload=None):
|
|||||||
# No import implies a `except:` catch, which catches
|
# No import implies a `except:` catch, which catches
|
||||||
# everything.
|
# everything.
|
||||||
return True
|
return True
|
||||||
|
|
||||||
for i in obj.inputs:
|
for i in obj.inputs:
|
||||||
except_classes = evaluator.eval_statement(i)
|
except_classes = evaluator.eval_statement(i)
|
||||||
for cls in except_classes:
|
for cls in except_classes:
|
||||||
|
|||||||
@@ -61,6 +61,11 @@ except Undefined:
|
|||||||
# inheritance
|
# inheritance
|
||||||
# -----------------
|
# -----------------
|
||||||
|
|
||||||
|
try:
|
||||||
|
undefined
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
# should catch everything
|
# should catch everything
|
||||||
try:
|
try:
|
||||||
undefined
|
undefined
|
||||||
|
|||||||
Reference in New Issue
Block a user