Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-126349: Add context managers to turtle for fill, poly and no_animation #126350

Merged
merged 30 commits into from
Jan 18, 2025

Conversation

MarieRoald
Copy link
Contributor

@MarieRoald MarieRoald commented Nov 3, 2024

Adds fill(), poly() and no_animation() context managers to turtle.py.

Co-authored-by: Yngve Mardal Moe [email protected]


📚 Documentation preview 📚: https://cpython-previews--126350.org.readthedocs.build/en/126350/library/turtle.html

@bedevere-app

This comment was marked as outdated.

blurb-it bot and others added 2 commits November 3, 2024 06:05
@Wulian233
Copy link
Contributor

LGTM
Recommend adding to what's new 3.14.rst

rruuaanng

This comment was marked as off-topic.

Copy link
Member

@Eclips4 Eclips4 left a comment

Choose a reason for hiding this comment

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

Could you please add a note about these additions to the Doc/whatsnew/3.14.rst?

Doc/library/turtle.rst Outdated Show resolved Hide resolved
Doc/library/turtle.rst Outdated Show resolved Hide resolved
Doc/library/turtle.rst Outdated Show resolved Hide resolved
Doc/library/turtle.rst Show resolved Hide resolved
Lib/turtle.py Show resolved Hide resolved
Lib/turtle.py Outdated Show resolved Hide resolved
Lib/turtle.py Outdated Show resolved Hide resolved
Lib/turtle.py Outdated Show resolved Hide resolved
Doc/library/turtle.rst Outdated Show resolved Hide resolved
Co-authored-by: Hugo van Kemenade <[email protected]>
Co-authored-by: Daniel Hollas <[email protected]>
Doc/library/turtle.rst Outdated Show resolved Hide resolved
Doc/library/turtle.rst Show resolved Hide resolved
Doc/library/turtle.rst Outdated Show resolved Hide resolved
Doc/library/turtle.rst Outdated Show resolved Hide resolved
Doc/library/turtle.rst Show resolved Hide resolved
Doc/library/turtle.rst Outdated Show resolved Hide resolved
Doc/library/turtle.rst Outdated Show resolved Hide resolved
Lib/test/test_turtle.py Outdated Show resolved Hide resolved
MarieRoald and others added 2 commits November 8, 2024 18:06
Doc/whatsnew/3.14.rst Outdated Show resolved Hide resolved
@yngvem
Copy link
Contributor

yngvem commented Nov 8, 2024

We have tried to address the review comments now 🙂

Copy link
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

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

Some final minor nitpicks. Otherwise looks great!

Doc/whatsnew/3.14.rst Outdated Show resolved Hide resolved
Lib/test/test_turtle.py Outdated Show resolved Hide resolved
Lib/test/test_turtle.py Outdated Show resolved Hide resolved
Lib/turtle.py Outdated Show resolved Hide resolved
Lib/turtle.py Outdated Show resolved Hide resolved
Lib/test/test_turtle.py Outdated Show resolved Hide resolved
Lib/test/test_turtle.py Outdated Show resolved Hide resolved
Doc/library/turtle.rst Outdated Show resolved Hide resolved
MarieRoald and others added 3 commits November 9, 2024 05:39
Co-authored-by: Marie Roald <[email protected]>
Co-authored-by: Marie Roald <[email protected]>
Copy link
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

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

Last one and I am good! (modulo Hugo's comment)

Doc/library/turtle.rst Show resolved Hide resolved
@hugovk
Copy link
Member

hugovk commented Dec 29, 2024

(Conflict resolved.)

@erlend-aasland Any more comments or good to merge?

@erlend-aasland erlend-aasland changed the title gh-126349 Add context managers to turtle for fill, poly and no_animation gh-126349: Add context managers to turtle for fill, poly and no_animation Dec 30, 2024
Co-authored-by: Yngve Mardal Moe <[email protected]>
Lib/test/test_turtle.py Outdated Show resolved Hide resolved
Copy link
Contributor

@graingert graingert left a comment

Choose a reason for hiding this comment

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

the mock.patch context manager handling in the tests could be improved

@yngvem
Copy link
Contributor

yngvem commented Jan 18, 2025

We've addressed the review comments now 🙂

@erlend-aasland erlend-aasland dismissed graingert’s stale review January 18, 2025 10:17

Remark was addressed

Copy link
Contributor

@erlend-aasland erlend-aasland left a comment

Choose a reason for hiding this comment

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

Thanks, everyone! :)

@erlend-aasland erlend-aasland merged commit d3adf02 into python:main Jan 18, 2025
38 checks passed
@vstinner
Copy link
Member

vstinner commented Jan 19, 2025

This change introduced a reference leak in test_turtle:

$ ./python -m test test_turtle -R 3:3
...
test_turtle leaked [13847, 13843, 13847] references, sum=41537
test_turtle leaked [3399, 3397, 3399] memory blocks, sum=10195
...

cc @encukou

@vstinner
Copy link
Member

I suspect that the regression comes from the new patch_screen() function in test_turtle.

@yngvem
Copy link
Contributor

yngvem commented Jan 20, 2025

I believe we found a fix. If we add the following teardown method to TestTurtle

    def tearDown(self):
        turtle.Turtle._screen = None
        return super().tearDown()

then @vstinner's command gives this output instead:

[...]
beginning 6 repetitions. Showing number of leaks (. for 0 or less, X for 10 or more)
123:456
XX. ...

== Tests result: SUCCESS ==
[...]

We're not sure how the workflow is for fixing regressions that we introduced. Should we make a new PR that starts with gh-126349:?

@hugovk
Copy link
Member

hugovk commented Jan 20, 2025

Should we make a new PR that starts with gh-126349:?

Yes please, because we've only just merged this PR, the fix can go under the same issue.

@yngvem
Copy link
Contributor

yngvem commented Jan 20, 2025

We'll submit a PR when we're off work today then :)

@hugovk
Copy link
Member

hugovk commented Jan 20, 2025

@encukou has created a fix at #129079.

srinivasreddy pushed a commit to srinivasreddy/cpython that referenced this pull request Jan 21, 2025
…ers to turtle (python#126350)

Co-authored-by: Marie Roald <[email protected]>
Co-authored-by: Yngve Mardal Moe <[email protected]>
Co-authored-by: Hugo van Kemenade <[email protected]>
Co-authored-by: Daniel Hollas <[email protected]>
Co-authored-by: Bénédikt Tran <[email protected]>
Co-authored-by: Erlend E. Aasland <[email protected]>
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.