Skip to content

Commit 6555082

Browse files
committed
CodeValidator now properly throws exceptions in Python 3.x
1 parent a411021 commit 6555082

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

splunklib/searchcommands/validators.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,12 @@ def __call__(self, value):
9595
try:
9696
return Code.object(compile(value, 'string', self._mode), six.text_type(value))
9797
except (SyntaxError, TypeError) as error:
98-
raise ValueError(error.message)
98+
if six.PY2:
99+
message = error.message
100+
else:
101+
message = str(error)
102+
103+
six.raise_from(ValueError(message), error)
99104

100105
def format(self, value):
101106
return None if value is None else value.source

0 commit comments

Comments
 (0)