Skip to content

gh-133656: Remove deprecated zipimport.zipimporter.load_module #133662

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

Wulian233
Copy link
Contributor

@Wulian233 Wulian233 commented May 8, 2025

@sharktide
Copy link
Contributor

@Wulian233

considering how pyhton imports work, You might have to modify the files that run on import or any references to load_module. This will be a really daunting task for you :( sorry!

@sharktide
Copy link
Contributor

@Wulian233 Will review tmrw

Copy link
Contributor

@sharktide sharktide left a comment

Choose a reason for hiding this comment

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

This PR seems sound, however I'll approve it after stanfromireland and hugovk resolve their conversation, because I am not sure either if it should or shouldn't be in the devguide either :)

Copy link
Contributor

@ncoghlan ncoghlan left a comment

Choose a reason for hiding this comment

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

There is some additional sys.path manipulation added to the test case that doesn't look like it should be necessary.

Otherwise this looks good to me.

@@ -552,17 +551,12 @@ def testZipImporterMethods(self):
"spam" + pyc_ext: test_pyc}
self.makeZip(files, file_comment=b"spam")

sys.path.insert(0, TEMP_ZIP)
Copy link
Contributor

Choose a reason for hiding this comment

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

This addition to the test case doesn't seem like it should be necessary.

@@ -671,15 +665,12 @@ def testZipImporterMethodsInSubDirectory(self):
packdir2 + TESTMOD + pyc_ext: test_pyc}
self.makeZip(files, file_comment=b"eggs")

sys.path.insert(0, TEMP_ZIP + os.sep + TESTPACK)
Copy link
Contributor

Choose a reason for hiding this comment

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

As above (this addition doesn't look correct)

@bedevere-app
Copy link

bedevere-app bot commented Aug 2, 2025

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@Wulian233
Copy link
Contributor Author

Wulian233 commented Aug 3, 2025

There is some additional sys.path manipulation added to the test case that doesn't look like it should be necessary.

Otherwise this looks good to me.

That's necessary. If these two lines are removed, the test will fail (p1)
2025-08-03 132623

with a ModuleNotFoundError because the modules cannot be found. If they are added back, the test passes. We need to make sure Python can find them, which maybe is the negative effect of removing load_module? I'm not an expert for this, and I don't know the underlying reasons for them, sorry

And sys.path.insert is also used in many other places in this file, for example:

https://github.com/Wulian233/cpython/blob/5616e27403799b481f44f96c3a21336fd03941c9/Lib/test/test_zipimport.py#L165
屏幕截图 2025-08-03 134313

https://github.com/Wulian233/cpython/blob/5616e27403799b481f44f96c3a21336fd03941c9/Lib/test/test_zipimport.py#L373

https://github.com/Wulian233/cpython/blob/5616e27403799b481f44f96c3a21336fd03941c9/Lib/test/test_zipimport.py#L420-L422
屏幕截图 2025-08-03 134236

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy