diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2016-03-03 21:19:55 +0000 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2016-06-04 10:07:36 +0100 |
commit | e1b66de78193b910707b665f1623d67dde86ac2f (patch) | |
tree | 44a233c2c1aa6a4324d6ade2d0c9de48eb41a8dc /astroid/objects.py | |
parent | e3272214736449a585620c00ebfd80286f3a5500 (diff) | |
download | astroid-git-e1b66de78193b910707b665f1623d67dde86ac2f.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/objects.py')
-rw-r--r-- | astroid/objects.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/astroid/objects.py b/astroid/objects.py index 6597f3e8..83074664 100644 --- a/astroid/objects.py +++ b/astroid/objects.py @@ -169,3 +169,14 @@ class Super(node_classes.NodeNG): def getattr(self, name, context=None): return list(self.igetattr(name, context=context)) + + +class ExceptionInstance(bases.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()) |