summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2020-04-28 08:35:15 +0200
committerClaudiu Popa <pcmanticore@gmail.com>2020-04-28 09:04:01 +0200
commitb9974d539b229dc63d49c2b5ebcd6b527aedb60b (patch)
tree3cf1b2711eb2685399840d9383086d05a0595012
parent6c8bfb4b7fb5366a3facfc08020c68ac426b9a8d (diff)
downloadastroid-git-b9974d539b229dc63d49c2b5ebcd6b527aedb60b.tar.gz
Handle the case where the raw builder fails to retrieve the ``__all__`` attribute
PyQT does something special with their objects and retrieving some of them (such as `__all__`) at runtime results in a RuntimeError. This patch simply swallows all the exceptions that accessing `__all__` might raise. Close #772
-rw-r--r--ChangeLog9
-rw-r--r--astroid/raw_building.py9
2 files changed, 17 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 272fd8f1..79497856 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,15 @@
astroid's ChangeLog
===================
+What's New in astroid 2.4.1?
+============================
+Release Date: TBA
+
+* Handle the case where the raw builder fails to retrieve the ``__all__`` attribute
+
+ Close #772
+
+
What's New in astroid 2.4.0?
============================
Release Date: 2020-04-27
diff --git a/astroid/raw_building.py b/astroid/raw_building.py
index a8a3b8a6..b2612778 100644
--- a/astroid/raw_building.py
+++ b/astroid/raw_building.py
@@ -276,6 +276,13 @@ def _build_from_function(node, name, member, module):
object_build_function(node, member, name)
+def _safe_has_attribute(obj, member):
+ try:
+ return hasattr(obj, member)
+ except Exception: # pylint: disable=broad-except
+ return False
+
+
class InspectBuilder:
"""class for building nodes from living object
@@ -357,7 +364,7 @@ class InspectBuilder:
# This should be called for Jython, where some builtin
# methods aren't caught by isbuiltin branch.
_build_from_function(node, name, member, self._module)
- elif hasattr(member, "__all__"):
+ elif _safe_has_attribute(member, "__all__"):
module = build_module(name)
_attach_local_node(node, module, name)
# recursion