Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tautils.py
diff options
context:
space:
mode:
authorWalter Bender <walter@sugarlabs.org>2010-03-17 03:35:40 (GMT)
committer Walter Bender <walter@sugarlabs.org>2010-03-17 03:35:40 (GMT)
commit1c3d5f00ed7f3407aaf0ada15a0c15a6138688bf (patch)
treea12da72c5ef58e8982a9e30114dab97bdefeb004 /tautils.py
parent7de0d034965317492da772ab28870ab00edbcb1f (diff)
type check on round_int
Diffstat (limited to 'tautils.py')
-rw-r--r--tautils.py10
1 files changed, 10 insertions, 0 deletions
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: