Skip to content

bpo-26571: Reinit class variable _RUNNING - #30355

Merged
serhiy-storchaka merged 5 commits into
python:mainfrom
williamnavaraj:patch-2
Aug 9, 2026
Merged

bpo-26571: Reinit class variable _RUNNING#30355
serhiy-storchaka merged 5 commits into
python:mainfrom
williamnavaraj:patch-2

Conversation

@williamnavaraj

@williamnavaraj williamnavaraj commented Jan 3, 2022

Copy link
Copy Markdown
Contributor

Initialising the class variable at the end of the object initialisation method. This will help to run this library smoothly in use cases such as in notebooks or GUI or other cell based or multiple turtle object instance execution. Otherwise it will raise Terminator error every second time. Will solve problems highlighted repeatedly in these stack overflow posts (With 1000s of views, current suggestions are some non-elegant workarounds such as importlib.reload(turtle) or or try-except and initializing again in the except as the _RUNNING becomes false at the end of last run or manually setting the _RUNNING flag). Logical to turn this to True after the initialization rather than during terminator exception. Change tested extensively and no issues found in any of the turtle-demo examples, notebooks or usual self-contained single instance execution.
https://stackoverflow.com/questions/45534458/python-turtle-terminator-even-after-using-exitonclick
https://stackoverflow.com/questions/34956937/weird-terminator-error-when-running-python-3-turtle-in-os-x
https://stackoverflow.com/questions/70252586/turtle-module-for-langtons-ant-in-python-giving-me-raise-terminator-turtle-ter
https://stackoverflow.com/questions/58078376/a-function-i-created-can-only-be-called-once-second-time-it-shows-an-error
https://stackoverflow.com/questions/54198108/how-can-i-close-a-window-after-using-turtle
https://stackoverflow.com/questions/67734319/running-turtle-multiple-times-but-receiving-a-terminator-error-after-the-first-r
https://stackoverflow.com/questions/43294665/turtle-done-not-working-in-spyder
https://stackoverflow.com/questions/50438762/python-turtle-window-crashes-every-2nd-time-running
https://stackoverflow.com/questions/41644324/how-to-close-python-turtle-properly
https://stackoverflow.com/questions/41548813/using-turtle-module-exitonclick/70552164
https://stackoverflow.com/questions/66750634/why-do-i-get-a-terminator-error-when-i-run-this-program
https://stackoverflow.com/questions/65546812/python-turtle-terminator
https://stackoverflow.com/questions/61963565/why-do-i-keep-getting-a-terminator-error-for-python-turtle

https://bugs.python.org/issue26571

@the-knights-who-say-ni

Copy link
Copy Markdown

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA).

CLA Missing

Our records indicate the following people have not signed the CLA:

@williamnavaraj

For legal reasons we need all the people listed to sign the CLA before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

If you have recently signed the CLA, please wait at least one business day
before our records are updated.

You can check yourself to see if the CLA has been received.

Thanks again for the contribution, we look forward to reviewing it!

@github-actions

github-actions Bot commented Feb 4, 2022

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Feb 4, 2022
@williamnavaraj

Copy link
Copy Markdown
Contributor Author

@serhiy-storchaka @ethanfurman PR became stale

@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label Feb 5, 2022
@gotyaoi gotyaoi mannequin mentioned this pull request Apr 10, 2022
@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Apr 10, 2026
williamnavaraj and others added 4 commits August 9, 2026 22:12
Initialising the class variable at the end of the object initialisation method. This will help to run this library smoothly in use cases such as in notebooks or GUI or other cell based or multiple turtle object instance execution. Otherwise it will raise Terminator error every second time. Will solve problems highlighted repeatedly in these stack overflow posts (With 1000s of views, current suggestions are some non-elegant workarounds such as importlib.reload(turtle) or or try-except and initializing again in the except as the _RUNNING becomes false at the end of last run or manually setting the _RUNNING flag).  Logical to turn this to True after the initialization rather than during terminator exception. Change tested extensively and no issues found in any of the turtle-demo examples, notebooks or usual self-contained single instance execution.
https://stackoverflow.com/questions/45534458/python-turtle-terminator-even-after-using-exitonclick
https://stackoverflow.com/questions/34956937/weird-terminator-error-when-running-python-3-turtle-in-os-x
https://stackoverflow.com/questions/70252586/turtle-module-for-langtons-ant-in-python-giving-me-raise-terminator-turtle-ter
https://stackoverflow.com/questions/58078376/a-function-i-created-can-only-be-called-once-second-time-it-shows-an-error
https://stackoverflow.com/questions/54198108/how-can-i-close-a-window-after-using-turtle
https://stackoverflow.com/questions/67734319/running-turtle-multiple-times-but-receiving-a-terminator-error-after-the-first-r
https://stackoverflow.com/questions/43294665/turtle-done-not-working-in-spyder
https://stackoverflow.com/questions/50438762/python-turtle-window-crashes-every-2nd-time-running
https://stackoverflow.com/questions/41644324/how-to-close-python-turtle-properly
https://stackoverflow.com/questions/41548813/using-turtle-module-exitonclick/70552164
https://stackoverflow.com/questions/66750634/why-do-i-get-a-terminator-error-when-i-run-this-program
https://stackoverflow.com/questions/65546812/python-turtle-terminator
https://stackoverflow.com/questions/61963565/why-do-i-keep-getting-a-terminator-error-for-python-turtle

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Rebased and cleaned up the comment and NEWS.

@serhiy-storchaka
serhiy-storchaka enabled auto-merge (squash) August 9, 2026 19:21
@serhiy-storchaka serhiy-storchaka added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes and removed stale Stale PR or inactive for long period of time. labels Aug 9, 2026
@serhiy-storchaka
serhiy-storchaka merged commit 1286d43 into python:main Aug 9, 2026
50 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @williamnavaraj for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Aug 9, 2026

Copy link
Copy Markdown

GH-155449 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Aug 9, 2026
@bedevere-app

bedevere-app Bot commented Aug 9, 2026

Copy link
Copy Markdown

GH-155450 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Aug 9, 2026
@bedevere-app

bedevere-app Bot commented Aug 9, 2026

Copy link
Copy Markdown

GH-155451 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Aug 9, 2026
serhiy-storchaka added a commit that referenced this pull request Aug 9, 2026
…0355) (GH-155451)

Creating a new turtle screen after the previous one was closed no longer
raises turtle.Terminator on the first turtle command.
(cherry picked from commit 1286d43)

Co-authored-by: williamnavaraj <williamnavaraj@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
serhiy-storchaka added a commit that referenced this pull request Aug 9, 2026
…0355) (GH-155450)

Creating a new turtle screen after the previous one was closed no longer
raises turtle.Terminator on the first turtle command.
(cherry picked from commit 1286d43)

Co-authored-by: williamnavaraj <williamnavaraj@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants