Skip to content

Commit 2085502

Browse files
committed
make sure exceptionholder message is a string
1 parent bb15cf0 commit 2085502

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

asteval/astutils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ def __init__(self, node, exc=None, msg='', expr=None, lineno=None):
327327
if self.exc is None and self.exc_info[0] is not None:
328328
self.exc = self.exc_info[0]
329329
if self.msg == '' and self.exc_info[1] is not None:
330-
self.msg = self.exc_info[1]
330+
self.msg = str(self.exc_info[1])
331331

332332
def get_error(self):
333333
"""Retrieve error data."""
@@ -350,6 +350,8 @@ def get_error(self):
350350
out.append(f"{exc_name}: {self.msg}")
351351
return (exc_name, '\n'.join(out))
352352

353+
def __repr__(self):
354+
return f"ExceptionHolder({self.exc}, {self.msg})"
353355

354356
class NameFinder(ast.NodeVisitor):
355357
"""Find all symbol names used by a parsed node."""

0 commit comments

Comments
 (0)