mirror of
https://github.com/progval/Limnoria.git
synced 2025-04-30 15:31:09 -05:00
Fix for a few exceptions escaping, bug #826177 in partciular.
This commit is contained in:
parent
37b796ac74
commit
487ac95d80
@ -152,6 +152,8 @@ class Math(callbacks.Privmsg):
|
|||||||
irc.error(msg, 'Go get scanez, this is a *real* math problem!')
|
irc.error(msg, 'Go get scanez, this is a *real* math problem!')
|
||||||
except TypeError:
|
except TypeError:
|
||||||
irc.error(msg, 'Something in there wasn\'t a valid number.')
|
irc.error(msg, 'Something in there wasn\'t a valid number.')
|
||||||
|
except NameError, e:
|
||||||
|
irc.error(msg, '%s is not a defined function.' % str(e).split()[1])
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
irc.error(msg, debug.exnToString(e))
|
irc.error(msg, debug.exnToString(e))
|
||||||
|
|
||||||
@ -194,7 +196,11 @@ class Math(callbacks.Privmsg):
|
|||||||
arg2 = stack.pop()
|
arg2 = stack.pop()
|
||||||
arg1 = stack.pop()
|
arg1 = stack.pop()
|
||||||
s = '%s%s%s' % (arg1, arg, arg2)
|
s = '%s%s%s' % (arg1, arg, arg2)
|
||||||
|
try:
|
||||||
stack.append(eval(s, self._mathEnv, self._mathEnv))
|
stack.append(eval(s, self._mathEnv, self._mathEnv))
|
||||||
|
except SyntaxError:
|
||||||
|
irc.error(msg, '%r is not a defined function.' % arg)
|
||||||
|
return
|
||||||
if len(stack) == 1:
|
if len(stack) == 1:
|
||||||
irc.reply(msg, str(self._complexToString(complex(stack[0]))))
|
irc.reply(msg, str(self._complexToString(complex(stack[0]))))
|
||||||
else:
|
else:
|
||||||
|
@ -47,6 +47,9 @@ class MathTestCase(PluginTestCase, PluginDocumentation):
|
|||||||
## self.assertNotError('calc log(8,2)')
|
## self.assertNotError('calc log(8,2)')
|
||||||
## self.assertNotError('calc log(8,2)')
|
## self.assertNotError('calc log(8,2)')
|
||||||
|
|
||||||
|
def testCalcNoNameError(self):
|
||||||
|
self.assertNotRegexp('calc foobar(x)', 'NameError')
|
||||||
|
|
||||||
def testRpn(self):
|
def testRpn(self):
|
||||||
self.assertResponse('rpn 5 2 +', '7')
|
self.assertResponse('rpn 5 2 +', '7')
|
||||||
self.assertResponse('rpn 1 2 3 +', 'Stack: [1, 5]')
|
self.assertResponse('rpn 1 2 3 +', 'Stack: [1, 5]')
|
||||||
@ -54,6 +57,9 @@ class MathTestCase(PluginTestCase, PluginDocumentation):
|
|||||||
self.assertResponse('rpn 2 3 4 + -', str(2-7))
|
self.assertResponse('rpn 2 3 4 + -', str(2-7))
|
||||||
self.assertNotError('rpn 2 degrees')
|
self.assertNotError('rpn 2 degrees')
|
||||||
|
|
||||||
|
def testRpmNoSyntaxError(self):
|
||||||
|
self.assertNotRegexp('rpn 2 3 foobar', 'SyntaxError')
|
||||||
|
|
||||||
def testConvert(self):
|
def testConvert(self):
|
||||||
self.assertResponse('convert 1 m to cm', '100.0 cm')
|
self.assertResponse('convert 1 m to cm', '100.0 cm')
|
||||||
self.assertResponse('convert 1 M to cm', '100.0 cm')
|
self.assertResponse('convert 1 M to cm', '100.0 cm')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user