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-112578: Fix RuntimeWarning when running zipfile #112579

Merged
merged 3 commits into from
Dec 3, 2023

Conversation

hauntsaninja
Copy link
Contributor

@hauntsaninja hauntsaninja commented Dec 1, 2023

@hauntsaninja hauntsaninja added needs backport to 3.12 bug and security fixes and removed needs backport to 3.12 bug and security fixes labels Dec 1, 2023
@hauntsaninja
Copy link
Contributor Author

hauntsaninja commented Dec 1, 2023

Hmm, actually zipfile.main has a much longer history of existing than just #98103. Maybe best thing to do is move main back into zipfile.__init__, and then we can safely backport this

@hauntsaninja hauntsaninja added the needs backport to 3.12 bug and security fixes label Dec 1, 2023
@hugovk
Copy link
Member

hugovk commented Dec 1, 2023

Can we test this somehow to prevent future regressions?

from ._path import ( # noqa: E402
Path,

# used privately for tests
CompleteDirs, # noqa: F401
)

# used privately for tests
from .__main__ import main # noqa: F401, E402
Copy link
Member

Choose a reason for hiding this comment

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

Maybe simply remove this import?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is what I did initially (see first commit). But I want to backport this change and I got worried because zipfile.main has existed for 15 years and that comment has only existed for one year.

I found one use in the wild too: https://github.com/ThoreBor/Anki_Leaderboard/blob/master/tools/ankiaddon.py

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

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

LGTM.

@serhiy-storchaka serhiy-storchaka merged commit 29e6c7b into python:main Dec 3, 2023
31 checks passed
@miss-islington-app
Copy link

Thanks @hauntsaninja for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

@bedevere-app
Copy link

bedevere-app bot commented Dec 3, 2023

GH-112646 is a backport of this pull request to the 3.12 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Dec 3, 2023
…2579)

(cherry picked from commit 29e6c7b)

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
@bedevere-app bedevere-app bot removed the needs backport to 3.12 bug and security fixes label Dec 3, 2023
@serhiy-storchaka
Copy link
Member

I agree, this is the right solution. __main__ should never be imported, it can only be executed.

serhiy-storchaka pushed a commit that referenced this pull request Dec 3, 2023
…GH-112646)

(cherry picked from commit 29e6c7b)

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Copy link
Member

@jaraco jaraco left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@hauntsaninja hauntsaninja deleted the gh112578 branch December 31, 2023 22:11
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
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.

None yet

4 participants