summaryrefslogtreecommitdiff
path: root/astroid/protocols.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/protocols.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/protocols.py')
-rw-r--r--astroid/protocols.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/astroid/protocols.py b/astroid/protocols.py
index a4172595..47741e33 100644
--- a/astroid/protocols.py
+++ b/astroid/protocols.py
@@ -34,6 +34,7 @@ from astroid.tree import treeabc
from astroid import util
raw_building = util.lazy_import('raw_building')
+objects = util.lazy_import('interpreter.objects')
def _reflected_name(name):
@@ -425,7 +426,8 @@ def _resolve_asspart(parts, assign_path, context):
def excepthandler_assigned_stmts(self, nodes, node=None, context=None, assign_path=None):
for assigned in inferenceutil.unpack_infer(self.type):
if isinstance(assigned, treeabc.ClassDef):
- assigned = assigned.instantiate_class()
+ assigned = objects.ExceptionInstance(assigned)
+
yield assigned
# Explicit StopIteration to return error information, see comment