From e3d1870d3341ef0170ef4792d1df8f5f5aed6576 Mon Sep 17 00:00:00 2001 From: Lafrite Date: Sun, 21 Dec 2014 16:03:53 +0100 Subject: [PATCH] Add exception for invalid expression --- pymath/render.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pymath/render.py b/pymath/render.py index 7044ff7..d26bfa2 100644 --- a/pymath/render.py +++ b/pymath/render.py @@ -40,7 +40,10 @@ class Render(object): else: operandeStack.push(self.render(token)()) - return operandeStack.pop() + if len(operandeStack) > 1: + raise ValueError("This postfix_tokens is not a valid expression") + else: + return operandeStack.pop() def txt_render(token): def render(*args):