mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-10 20:22:36 +01:00
commands: Handle OverflowError in _int
Signed-off-by: James McCoy <jamessan@users.sourceforge.net>
This commit is contained in:
parent
58e7e61d69
commit
e7d0bfd2d0
@ -211,7 +211,10 @@ def _int(s):
|
|||||||
return int(s, base)
|
return int(s, base)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
if base == 10:
|
if base == 10:
|
||||||
return int(float(s))
|
try:
|
||||||
|
return int(float(s))
|
||||||
|
except OverflowError:
|
||||||
|
raise ValueError('I don\'t understand numbers that large.')
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
@ -72,6 +72,7 @@ class GeneralContextTestCase(CommandsTestCase):
|
|||||||
def testSpecInt(self):
|
def testSpecInt(self):
|
||||||
self.assertState(['int'], ['1'], [1])
|
self.assertState(['int'], ['1'], [1])
|
||||||
self.assertState(['int', 'int', 'int'], ['1', '2', '3'], [1, 2, 3])
|
self.assertState(['int', 'int', 'int'], ['1', '2', '3'], [1, 2, 3])
|
||||||
|
self.assertError(['int'], ['9e999'])
|
||||||
|
|
||||||
def testSpecNick(self):
|
def testSpecNick(self):
|
||||||
strict = conf.supybot.protocols.irc.strictRfc()
|
strict = conf.supybot.protocols.irc.strictRfc()
|
||||||
|
Loading…
Reference in New Issue
Block a user