diff options
author | Daniël van Noord <13665637+DanielNoord@users.noreply.github.com> | 2022-07-08 14:04:52 +0200 |
---|---|---|
committer | Daniël van Noord <13665637+DanielNoord@users.noreply.github.com> | 2022-07-08 14:10:22 +0200 |
commit | 6fec464be57a9db182dc25466e82bc49f68cd121 (patch) | |
tree | 1862457d6695cb3863c4195d90d2eb3a33cd82ab /astroid/inference.py | |
parent | 3ab9af6e2e9c7df09c47c9368d022a9180d6c837 (diff) | |
download | astroid-git-6fec464be57a9db182dc25466e82bc49f68cd121.tar.gz |
Fix a crash involving properties within ``try ... except`` blocks
Diffstat (limited to 'astroid/inference.py')
-rw-r--r-- | astroid/inference.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/astroid/inference.py b/astroid/inference.py index de1535d3..7286b68c 100644 --- a/astroid/inference.py +++ b/astroid/inference.py @@ -1152,6 +1152,9 @@ def infer_functiondef( property_already_in_parent_locals = self.name in parent_frame.locals and any( isinstance(val, objects.Property) for val in parent_frame.locals[self.name] ) + # We also don't want to pass parent if the definition is within a Try node + if isinstance(self.parent, (nodes.TryExcept, nodes.TryFinally)): + property_already_in_parent_locals = True prop_func = objects.Property( function=self, |