Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tautils.py12
-rw-r--r--tawindow.py4
2 files changed, 11 insertions, 5 deletions
diff --git a/tautils.py b/tautils.py
index 77eb3f5..f95cd64 100644
--- a/tautils.py
+++ b/tautils.py
@@ -40,8 +40,10 @@ from taconstants import STRING_OR_NUMBER_ARGS, HIDE_LAYER, CONTENT_ARGS, \
from StringIO import StringIO
import os.path
from gettext import gettext as _
+import logging
+_logger = logging.getLogger('turtleart-activity')
-class logoerror(Exception):
+class pythonerror(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
@@ -266,12 +268,16 @@ def round_int(num):
try:
float(num)
except TypeError:
- raise logoerror("#syntaxerror")
+ _logger.debug("error trying to convert %s to number" % (str(num)))
+ raise pythonerror("#syntaxerror")
if int(float(num)) == num:
return int(num)
else:
- _nn = int(float(num+0.05)*10)/10.
+ if float(num)<0:
+ _nn = int((float(num)-0.005)*100)/100.
+ else:
+ _nn = int((float(num)+0.005)*100)/100.
if int(float(_nn)) == _nn:
return int(_nn)
return _nn
diff --git a/tawindow.py b/tawindow.py
index 57224f4..775c0c6 100644
--- a/tawindow.py
+++ b/tawindow.py
@@ -1837,9 +1837,9 @@ class TurtleArtWindow():
if btype in CONTENT_BLOCKS or btype in COLLAPSIBLE:
if btype == 'number':
try:
- values = [int(value)]
+ values = [round_int(value)]
except ValueError:
- values = [float(value)]
+ values = [0]
elif btype in COLLAPSIBLE:
if value is not None:
values = [int(value)]