From 40bdec92ca655052d7645198df2f728b6936114f Mon Sep 17 00:00:00 2001 From: Daniel Folkinshteyn Date: Mon, 22 Oct 2012 11:24:28 -0400 Subject: [PATCH] Math: calc: coerce argument to ascii string. working with unicode errors on the translate() step. --- plugins/Math/plugin.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugins/Math/plugin.py b/plugins/Math/plugin.py index 252744f35..6efa6da03 100644 --- a/plugins/Math/plugin.py +++ b/plugins/Math/plugin.py @@ -160,6 +160,13 @@ class Math(callbacks.Plugin): crash to the bot with something like '10**10**10**10'. One consequence is that large values such as '10**24' might not be exact. """ + try: + text = str(text) + except UnicodeEncodeError: + irc.error("There's no reason you should have fancy non-ASCII " + "characters in your mathematical expression. " + "Please remove them.") + return if text != text.translate(utils.str.chars, '_[]'): irc.error('There\'s really no reason why you should have ' 'underscores or brackets in your mathematical '