mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-25 04:02:46 +01:00
Math: Display a nicer error in case of MemoryError.
This commit is contained in:
parent
2dddfefa98
commit
78a50c81bd
@ -149,6 +149,8 @@ class Math(callbacks.Plugin):
|
|||||||
irc.error(_('Invalid syntax: %s') % e.args[0])
|
irc.error(_('Invalid syntax: %s') % e.args[0])
|
||||||
except NameError as e:
|
except NameError as e:
|
||||||
irc.error(_('%s is not a defined function.') % e.args[0])
|
irc.error(_('%s is not a defined function.') % e.args[0])
|
||||||
|
except MemoryError:
|
||||||
|
irc.error(_('Memory error (too much recursion?)'))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
irc.error(str(e))
|
irc.error(str(e))
|
||||||
calc = wrap(calc, ['text'])
|
calc = wrap(calc, ['text'])
|
||||||
|
@ -135,6 +135,9 @@ class MathTestCase(PluginTestCase):
|
|||||||
def testCalcStrFloat(self):
|
def testCalcStrFloat(self):
|
||||||
self.assertResponse('calc 3+33333333333333', '33333333333336')
|
self.assertResponse('calc 3+33333333333333', '33333333333336')
|
||||||
|
|
||||||
|
def testCalcMemoryError(self):
|
||||||
|
self.assertRegexp('calc ' + '('*500, 'too much recursion')
|
||||||
|
|
||||||
def testICalc(self):
|
def testICalc(self):
|
||||||
self.assertResponse('icalc 1^1', '0')
|
self.assertResponse('icalc 1^1', '0')
|
||||||
self.assertResponse('icalc 10**24', '1' + '0'*24)
|
self.assertResponse('icalc 10**24', '1' + '0'*24)
|
||||||
|
Loading…
Reference in New Issue
Block a user