diff options
author | Marion <marion.zepf@gmail.com> | 2013-07-26 11:54:50 (GMT) |
---|---|---|
committer | Marion <marion.zepf@gmail.com> | 2013-07-26 11:54:50 (GMT) |
commit | 3ac65bc4d1390c5d0ff866a0e05ab45bbf05f133 (patch) | |
tree | 49fb112e75c61e7f4b3326ecc2dda44f9c1a29bf /TurtleArt | |
parent | 507c3ca2d25b90120d3ff2d2b425c8e44f35de98 (diff) |
fix 'forever' block
Diffstat (limited to 'TurtleArt')
-rw-r--r-- | TurtleArt/tabasics.py | 2 | ||||
-rw-r--r-- | TurtleArt/taprimitive.py | 13 |
2 files changed, 5 insertions, 10 deletions
diff --git a/TurtleArt/tabasics.py b/TurtleArt/tabasics.py index caedd1e..1b7c57b 100644 --- a/TurtleArt/tabasics.py +++ b/TurtleArt/tabasics.py @@ -822,7 +822,7 @@ number of seconds')) help_string=_('loops forever')) self.tw.lc.def_prim('forever', 1, Primitive(self.tw.lc.loop, - constant_args={0: Primitive(Primitive.controller_forever)}), + constant_args={0: Primitive(Primitive.controller_forever)()}), True) primitive_dictionary['repeat'] = self._prim_repeat diff --git a/TurtleArt/taprimitive.py b/TurtleArt/taprimitive.py index 3f13412..ceb8992 100644 --- a/TurtleArt/taprimitive.py +++ b/TurtleArt/taprimitive.py @@ -166,20 +166,14 @@ class Primitive(object): # replace or remove the first argument if it is a LogoCode instance first_arg = None - if runtime_args and isinstance(runtime_args[0], LogoCode): - (lc, runtime_args) = (runtime_args[0], runtime_args[1:]) + if all_args and isinstance(all_args[0], LogoCode): + (lc, all_args) = (all_args[0], all_args[1:]) if self.wants_turtle(): first_arg = lc.tw.turtles.get_active_turtle() elif self.wants_canvas(): first_arg = lc.tw.canvas elif self.wants_logocode(): first_arg = lc - elif self.wants_nothing(): - first_arg = None - else: - # TODO what error to raise? - # TODO better message - raise TypeError("cannot handle method of unknown class") # slot wrappers (new_args, new_kwargs) = self._apply_wrappers(all_args, all_kwargs) @@ -310,7 +304,8 @@ class Primitive(object): @staticmethod def controller_forever(): """ Loop controller for the 'forever' block """ - yield True + while True: + yield True @staticmethod def do_nothing(): |