Skip to content

Catch turtle.Terminator exceptions in turtledemo #66022

Closed

Description

@terryjreedy
BPO 21823
Nosy @terryjreedy

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/terryjreedy'
closed_at = <Date 2014-06-22.05:24:00.782>
created_at = <Date 2014-06-22.04:15:08.433>
labels = ['type-bug']
title = 'Catch turtle.Terminator exceptions in turtledemo'
updated_at = <Date 2014-06-22.06:27:42.462>
user = 'https://github.com/terryjreedy'

bugs.python.org fields:

activity = <Date 2014-06-22.06:27:42.462>
actor = 'terry.reedy'
assignee = 'terry.reedy'
closed = True
closed_date = <Date 2014-06-22.05:24:00.782>
closer = 'terry.reedy'
components = []
creation = <Date 2014-06-22.04:15:08.433>
creator = 'terry.reedy'
dependencies = []
files = []
hgrepos = []
issue_num = 21823
keywords = []
message_count = 4.0
messages = ['221215', '221216', '221217', '221221']
nosy_count = 2.0
nosy_names = ['terry.reedy', 'python-dev']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue21823'
versions = ['Python 2.7', 'Python 3.4', 'Python 3.5']

Activity

  1. terryjreedy commented on Jun 22, 2014

    @terryjreedy
    MemberAuthor

    When a turtle update operation cannot finish because the underlying canvas has been cleared (when the STOP button is pushed), turtle.Terminator is raised. When turtledemo runs the main function of a demo, it catches any Termininator raised before main returns.

    However, special demos leave an event loop running after main returns. If the demo is free running, as with clock and minimal_hanoi, clicking STOP causes such exceptions. (This is not be a problem with paint as updates only happen in response to mouse events on the canvas and complete before a user could move the mouse to the STOP button.)

    This is the clock trackback, with common file prefix removed:
    \tkinter\init.py", line 1487, in __call__
    return self.func(*args)
    \tkinter\init.py", line 532, in callit
    func(*args)
    \turtledemo\clock.py", line 116, in tick
    second_hand.setheading(6*sekunde)
    \turtle.py", line 1935, in setheading
    self._rotate(angle)
    \turtle.py", line 3277, in _rotate
    self._update()
    \turtle.py", line 2659, in _update
    self._update_data()
    \turtle.py", line 2645, in _update_data
    self.screen._incrementudc()
    \turtle.py", line 1291, in _incrementudc
    raise Terminator

    The hanoi traceback starts differently:
    \tkinter\init.py", line 1487, in __call__
    return self.func(*args)
    \turtle.py", line 686, in eventfun
    fun()
    \turtledemo\minimal_hanoi.py", line 53, in play
    hanoi(6, t1, t2, t3)
    ...<5 recursive calls deleted>
    \turtledemo\minimal_hanoi.py", line 36, in push
    to_.push(from_.pop())
    \turtledemo\minimal_hanoi.py", line 36, in push
    d.setx(self.x)
    \turtle.py", line 1807, in setx
    self._goto(Vec2D(x, self._position[1]))
    \turtle.py", line 3178, in _goto
    <last 3 lines as above>

    These exceptions and tracebacks do not stop the master demo window, but are printed to the console (python -m turtledemo) or Idle Shell (open in editor, run). They are ugly, might unnecessarily alarm a naive user, or falsely teach that tracebacks are to be ignored.

    In the patch to clock.tick, I put try: at the top, to be safe, although just before the update of the second hand might be good enough.

  2. self-assigned this
    on Jun 22, 2014
  3. python-dev commented on Jun 22, 2014

    python-devmannequin
    Mannequin

    New changeset a43d03cdf38b by Terry Jan Reedy in branch '2.7':
    Issue bpo-21823: Catch turtle.Terminator exceptions in turtledemo.
    http://hg.python.org/cpython/rev/a43d03cdf38b

    New changeset 1ae2382417dc by Terry Jan Reedy in branch '3.4':
    Issue bpo-21823: Catch turtle.Terminator exceptions in turtledemo.
    http://hg.python.org/cpython/rev/1ae2382417dc

  4. terryjreedy commented on Jun 22, 2014

    @terryjreedy
    MemberAuthor

    In 2.7, the exception in tick occurred at tracer(False), so I moved try: up in all patches.

  5. terryjreedy commented on Jun 22, 2014

    @terryjreedy
    MemberAuthor

    Since hanoi do not have user interaction, once started, it does not need to be 'special'. Like planets_and_moon, it could run until done and then return 'Done'.

  6. transferred this issue fromon Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

type-bugAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions