From 29b2bdc856196bbad77fc6200cb1c6463f89e206 Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Thu, 18 Mar 2010 17:54:38 +0000 Subject: fixed bug in loading of floats from saved projects --- 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)] -- cgit v0.9.1