summaryrefslogtreecommitdiff
path: root/astroid/builder.py
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2019-11-17 21:22:39 +0100
committerClaudiu Popa <pcmanticore@gmail.com>2019-11-17 21:22:39 +0100
commit05a9106b539182610c1153fbe6ad6fbe8a6d7d58 (patch)
tree06c3370d187311de7e46e72bdd2423d1a99eec60 /astroid/builder.py
parentb55fc8d9731e3527ab9c4c34488a6471d0aca62f (diff)
downloadastroid-git-05a9106b539182610c1153fbe6ad6fbe8a6d7d58.tar.gz
Allow attribute assignment for exception instances
Diffstat (limited to 'astroid/builder.py')
-rw-r--r--astroid/builder.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/astroid/builder.py b/astroid/builder.py
index ac71093d..34bde0a1 100644
--- a/astroid/builder.py
+++ b/astroid/builder.py
@@ -32,6 +32,8 @@ from astroid import rebuilder
from astroid import nodes
from astroid import util
+objects = util.lazy_import("objects")
+
# The name of the transient function that is used to
# wrap expressions to be extracted when calling
# extract_node.
@@ -224,14 +226,15 @@ class AstroidBuilder(raw_building.InspectBuilder):
if inferred is util.Uninferable:
continue
try:
- if inferred.__class__ is bases.Instance:
+ cls = inferred.__class__
+ if cls is bases.Instance or cls is objects.ExceptionInstance:
inferred = inferred._proxied
iattrs = inferred.instance_attrs
if not _can_assign_attr(inferred, node.attrname):
continue
elif isinstance(inferred, bases.Instance):
- # Const, Tuple, ... we may be wrong, may be not, but
- # anyway we don't want to pollute builtin's namespace
+ # Const, Tuple or other containers that inherit from
+ # `Instance`
continue
elif inferred.is_function:
iattrs = inferred.instance_attrs