summaryrefslogtreecommitdiff
path: root/astroid/bases.py
diff options
context:
space:
mode:
authorBryce Guinta <bryce.paul.guinta@gmail.com>2018-07-04 02:57:30 -0600
committerBryce Guinta <bryce.guinta@protonmail.com>2018-07-05 23:17:06 -0600
commitfc9ba9412e40578143ef260761353bfe2cb0afdb (patch)
tree47bbe08b48140e96f1fb992b53cc72b8f314f4b3 /astroid/bases.py
parentaea774e9554877871045f7f5d0a2f6e063a7c756 (diff)
downloadastroid-git-fc9ba9412e40578143ef260761353bfe2cb0afdb.tar.gz
Allow technically valid (but weird) type.__new__ calls
Ignore non-string keys
Diffstat (limited to 'astroid/bases.py')
-rw-r--r--astroid/bases.py14
1 files changed, 5 insertions, 9 deletions
diff --git a/astroid/bases.py b/astroid/bases.py
index 4401c8a2..fa9ca00a 100644
--- a/astroid/bases.py
+++ b/astroid/bases.py
@@ -376,8 +376,7 @@ class BoundMethod(UnboundMethod):
In order for such call to be valid, the metaclass needs to be
a subtype of ``type``, the name needs to be a string, the bases
- needs to be a tuple of classes and the attributes a dictionary
- of strings to values.
+ needs to be a tuple of classes
"""
from astroid import node_classes
# Verify the metaclass
@@ -419,13 +418,10 @@ class BoundMethod(UnboundMethod):
for key, value in attrs.items:
key = next(key.infer(context=context))
value = next(value.infer(context=context))
- if key.__class__.__name__ != 'Const':
- # Something invalid as an attribute.
- return None
- if not isinstance(key.value, str):
- # Not a proper attribute.
- return None
- cls_locals[key.value].append(value)
+ # Ignore non string keys
+ if (key.__class__.__name__ == 'Const' and
+ isinstance(key.value, str)):
+ cls_locals[key.value].append(value)
# Build the class from now.
cls = mcs.__class__(name=name.value, lineno=caller.lineno,