summaryrefslogtreecommitdiff
path: root/astroid/interpreter/objects.py
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2016-03-03 21:19:55 +0000
committerClaudiu Popa <pcmanticore@gmail.com>2016-03-03 21:19:55 +0000
commita315ef29ff51ff861cb5111d706bc17d6375f0de (patch)
treed3567dd277ece40ae2c378377d2b0afe6ebd75c8 /astroid/interpreter/objects.py
parent9613be5921f777fc0a41269f869e20a4e7124834 (diff)
downloadastroid-git-a315ef29ff51ff861cb5111d706bc17d6375f0de.tar.gz
Exceptions have their own object model
Some of exceptions's attributes, such as .args and .message, can't be inferred correctly since they are descriptors that get transformed into the proper objects at runtime. This can cause issues with the static analysis, since they are inferred as different than what's expected. Now when we're creating instances of exceptions, we're inferring a special object that knows how to transform those runtime attributes into the proper objects via a custom object model. Closes #81
Diffstat (limited to 'astroid/interpreter/objects.py')
-rw-r--r--astroid/interpreter/objects.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/astroid/interpreter/objects.py b/astroid/interpreter/objects.py
index 3c61aef4..237caad6 100644
--- a/astroid/interpreter/objects.py
+++ b/astroid/interpreter/objects.py
@@ -277,6 +277,18 @@ class Instance(BaseInstance):
node=self, index=index, context=context))
+@util.register_implementation(runtimeabc.ExceptionInstance)
+class ExceptionInstance(Instance):
+ """Class for instances of exceptions
+
+ It has special treatment for some of the exceptions's attributes,
+ which are transformed at runtime into certain concrete objects, such as
+ the case of .args.
+ """
+
+ special_attributes = util.lazy_descriptor(lambda: objectmodel.ExceptionInstanceModel())
+
+
class Method(Proxy):
def __repr__(self):