mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-02 17:29:22 +01:00
Math: calc: coerce argument to ascii string. working with unicode errors on the translate() step.
This commit is contained in:
parent
463f0c0184
commit
40bdec92ca
@ -160,6 +160,13 @@ class Math(callbacks.Plugin):
|
|||||||
crash to the bot with something like '10**10**10**10'. One consequence
|
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.
|
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, '_[]'):
|
if text != text.translate(utils.str.chars, '_[]'):
|
||||||
irc.error('There\'s really no reason why you should have '
|
irc.error('There\'s really no reason why you should have '
|
||||||
'underscores or brackets in your mathematical '
|
'underscores or brackets in your mathematical '
|
||||||
|
Loading…
Reference in New Issue
Block a user