Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork34.2k
gh-91167: Fix cloned turtle pen not clearing completely#145406
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -671,6 +671,21 @@ def test_dot_signature(self): | ||
| self.assertRaises(turtle.TurtleGraphicsError, self.turtle.dot, 0, (0, 257, 0)) | ||
| self.assertRaises(turtle.TurtleGraphicsError, self.turtle.dot, 0, 0, 257, 0) | ||
| def test_clone_clear_does_not_delete_source_items(self): | ||
| screen = self.turtle.screen | ||
| screen._delete.reset_mock() | ||
| screen._createline.side_effect = lambda: object() | ||
| self.turtle.circle(20) | ||
| clone = self.turtle.clone() | ||
| source_items = set(self.turtle.items) | ||
| clone.forward(50) | ||
| clone.clear() | ||
| deleted_items = {call.args[0] for call in screen._delete.call_args_list} | ||
| self.assertFalse(source_items & deleted_items) | ||
Comment on lines +674 to +688 CopilotAI | ||
| class TestModuleLevel(unittest.TestCase): | ||
| def test_all_signatures(self): | ||
| import inspect | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -2879,6 +2879,8 @@ def clone(self): | ||||||||||||||||||||||||||||||||||||||||||||||||
| q.turtle._item = [screen._createpoly() for item in | ||||||||||||||||||||||||||||||||||||||||||||||||
| screen._shapes[self.turtle.shapeIndex]._data] | ||||||||||||||||||||||||||||||||||||||||||||||||
| q.currentLineItem = screen._createline() | ||||||||||||||||||||||||||||||||||||||||||||||||
| q.currentLine = [q._position] if q._drawing else [] | ||||||||||||||||||||||||||||||||||||||||||||||||
| q.items = [q.currentLineItem] | ||||||||||||||||||||||||||||||||||||||||||||||||
CopilotAI | ||||||||||||||||||||||||||||||||||||||||||||||||
| q.items= [q.currentLineItem] | |
| q.items= [q.currentLineItem] | |
| # Reset ownership/undo state so the clone cannot affect the source | |
| # turtle's existing canvas items via non-clear operations. | |
| # The transient animation line item will be recreated on demand. | |
| ifhasattr(q,"drawingLineItem"): | |
| q.drawingLineItem=None | |
| # The clone should start with no stamps of its own. | |
| ifhasattr(q,"stampItems"): | |
| q.stampItems= [] | |
| # Clear the clone's undo history so q.undo() cannot replay or | |
| # delete items created before cloning. | |
| ifhasattr(q,"undobuffer"): | |
| reset=getattr(q.undobuffer,"reset",None) | |
| ifcallable(reset): | |
| reset() | |
| # If a fill operation is active on the source, avoid sharing the | |
| # same fill item/path ids with the clone. | |
| ifhasattr(q,"_fillitem")andgetattr(self,"_fillitem",None)isnotNone: | |
| q._fillitem=None | |
| ifhasattr(q,"_fillpath")andgetattr(self,"_fillitem",None)isnotNone: | |
| q._fillpath= [] |
Uh oh!
There was an error while loading.Please reload this page.