commands: Handle OverflowError in _int

Signed-off-by: James McCoy <jamessan@users.sourceforge.net>
This commit is contained in:
James McCoy 2013-08-23 23:36:44 -04:00
parent 58e7e61d69
commit e7d0bfd2d0
2 changed files with 5 additions and 1 deletions

View File

@ -211,7 +211,10 @@ def _int(s):
return int(s, base)
except ValueError:
if base == 10:
return int(float(s))
try:
return int(float(s))
except OverflowError:
raise ValueError('I don\'t understand numbers that large.')
else:
raise

View File

@ -72,6 +72,7 @@ class GeneralContextTestCase(CommandsTestCase):
def testSpecInt(self):
self.assertState(['int'], ['1'], [1])
self.assertState(['int', 'int', 'int'], ['1', '2', '3'], [1, 2, 3])
self.assertError(['int'], ['9e999'])
def testSpecNick(self):
strict = conf.supybot.protocols.irc.strictRfc()