diff --git a/asteval/astutils.py b/asteval/astutils.py index 3b458ad..c8b5df0 100644 --- a/asteval/astutils.py +++ b/asteval/astutils.py @@ -520,7 +520,13 @@ def __setattr__(self, attr, val): self.__dict__[attr] = val def __dir__(self): - return ['name'] + return ['_getdoc', 'argnames', 'kwargs', 'name', 'vararg', 'varkws'] + + def _getdoc(self): + doc = self.__doc__ + if isinstance(doc, ast.Constant): + doc = doc.s + return doc def __repr__(self): """TODO: docstring in magic method.""" @@ -538,8 +544,9 @@ def __repr__(self): if self.varkws is not None: sig = f"%sig, **{self.varkws}" sig = f"" - if self.__doc__ is not None: - sig = f"{sig}\n {self.__doc__}" + doc = self._getdoc() + if doc is not None: + sig = f"{sig}\n {doc}" return sig def __call__(self, *args, **kwargs):