From 1c3d5f00ed7f3407aaf0ada15a0c15a6138688bf Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Wed, 17 Mar 2010 03:35:40 +0000 Subject: type check on round_int --- diff --git a/tautils.py b/tautils.py index a0361e8..12812db 100644 --- a/tautils.py +++ b/tautils.py @@ -41,6 +41,11 @@ from StringIO import StringIO import os.path from gettext import gettext as _ +class logoerror(Exception): + def __init__(self, value): + self.value = value + def __str__(self): + return repr(self.value) ''' The strategy for mixing numbers and strings is to first try @@ -241,6 +246,11 @@ def text_media_type(name): def round_int(num): """ Remove trailing decimal places if number is an int """ + try: + float(num) + except TypeError: + raise logoerror("#syntaxerror") + if int(float(num)) == num: return int(num) else: -- cgit v0.9.1