Some more Python compatibility improvements.

This commit is contained in:
Dave Halter
2016-07-03 11:35:07 +02:00
parent 10b8936b11
commit 62786158da
2 changed files with 8 additions and 7 deletions

View File

@@ -104,9 +104,6 @@ class CompiledObject(Base):
return _parse_function_doc(self.doc)
def api_type(self):
if fake.is_class_instance(self.obj):
return 'instance'
obj = self.obj
if inspect.isclass(obj):
return 'class'
@@ -115,7 +112,8 @@ class CompiledObject(Base):
elif inspect.isbuiltin(obj) or inspect.ismethod(obj) \
or inspect.ismethoddescriptor(obj) or inspect.isfunction(obj):
return 'function'
raise NotImplementedError
# Everything else...
return 'instance'
@property
def type(self):
@@ -190,8 +188,11 @@ class CompiledObject(Base):
@property
def name(self):
# might not exist sometimes (raises AttributeError)
return FakeName(self._get_class().__name__, self)
try:
name = self._get_class().__name__
except AttributeError:
name = repr(self.obj)
return FakeName(name, self)
def _execute_function(self, params):
if self.type != 'funcdef':

View File

@@ -7,7 +7,7 @@ Fallback to callee definition when definition not found.
"""Parenthesis closed at next line."""
# Ignore these definitions for a little while, not sure if we really want them.
# python <= 2.7
# python <= 2.5
#? isinstance
isinstance(