KEMBAR78
gh-133656: Remove deprecated `zipimport.zipimporter.load_module` by Wulian233 · Pull Request #133662 · python/cpython · GitHub
Skip to content

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.

@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

@Wulian233 Wulian233 requested a review from ncoghlan August 11, 2025 02:03
@ncoghlan
Copy link
Contributor

@Wulian233 You're right, the importlib.import_module lines were previously only passing because the prior zi.load_module call had left sys.modules["TESTPACK"] populated.

Given that, it makes sense to keep the path manipulation additions, but move them as far down in their respective test cases as possible to still let the everything pass (which should be just before the importlib.import_module line in each case, since the direct instantiation shouldn't care if the zip archive is on sys.path or not, while importlib.import_module does care).

@Wulian233 Wulian233 requested a review from AA-Turner as a code owner August 11, 2025 13:16
@Wulian233
Copy link
Contributor Author

I have made the requested changes; please review again

thanks!

@bedevere-app
Copy link

bedevere-app bot commented Aug 11, 2025

Thanks for making the requested changes!

@ncoghlan: please review the changes made to this pull request.

@gpshead gpshead enabled auto-merge (squash) August 30, 2025 01:08
@gpshead gpshead merged commit 5c6937a into python:main Aug 30, 2025
48 of 49 checks passed
@bedevere-bot
Copy link

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot ARM64 Raspbian 3.x (tier-3) has failed when building commit 5c6937a.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/#/builders/1678/builds/742) and take a look at the build logs.
  4. Check if the failure is related to this commit (5c6937a) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/#/builders/1678/builds/742

Failed tests:

  • test.test_multiprocessing_fork.test_processes

Failed subtests:

  • test_interrupt - test.test_multiprocessing_fork.test_processes.WithProcessesTestProcess.test_interrupt

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File "/home/stan/buildarea/3.x.stan-raspbian.nondebug/build/Lib/contextlib.py", line 85, in inner
    return func(*args, **kwds)
  File "/home/stan/buildarea/3.x.stan-raspbian.nondebug/build/Lib/test/_test_multiprocessing.py", line 596, in test_interrupt
    exitcode = self._kill_process(multiprocessing.Process.interrupt)
  File "/home/stan/buildarea/3.x.stan-raspbian.nondebug/build/Lib/contextlib.py", line 85, in inner
    return func(*args, **kwds)
  File "/home/stan/buildarea/3.x.stan-raspbian.nondebug/build/Lib/test/_test_multiprocessing.py", line 577, in _kill_process
    self.assertEqual(join(), None)
                     ~~~~^^
  File "/home/stan/buildarea/3.x.stan-raspbian.nondebug/build/Lib/test/_test_multiprocessing.py", line 250, in __call__
    return self.func(*args, **kwds)
           ~~~~~~~~~^^^^^^^^^^^^^^^
  File "/home/stan/buildarea/3.x.stan-raspbian.nondebug/build/Lib/multiprocessing/process.py", line 156, in join
    res = self._popen.wait(timeout)
  File "/home/stan/buildarea/3.x.stan-raspbian.nondebug/build/Lib/multiprocessing/popen_fork.py", line 44, in wait
    return self.poll(os.WNOHANG if timeout == 0.0 else 0)
           ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stan/buildarea/3.x.stan-raspbian.nondebug/build/Lib/multiprocessing/popen_fork.py", line 28, in poll
    pid, sts = os.waitpid(self.pid, flag)
               ~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "/home/stan/buildarea/3.x.stan-raspbian.nondebug/build/Lib/test/_test_multiprocessing.py", line 573, in handler
    raise RuntimeError('join took too long: %s' % p)
RuntimeError: join took too long: <Process name='Process-1' pid=226230 parent=226228 started daemon>


Traceback (most recent call last):
  File "/home/stan/buildarea/3.x.stan-raspbian.nondebug/build/Lib/contextlib.py", line 85, in inner
    return func(*args, **kwds)
  File "/home/stan/buildarea/3.x.stan-raspbian.nondebug/build/Lib/test/_test_multiprocessing.py", line 596, in test_interrupt
    exitcode = self._kill_process(multiprocessing.Process.interrupt)
  File "/home/stan/buildarea/3.x.stan-raspbian.nondebug/build/Lib/contextlib.py", line 85, in inner
    return func(*args, **kwds)
  File "/home/stan/buildarea/3.x.stan-raspbian.nondebug/build/Lib/test/_test_multiprocessing.py", line 577, in _kill_process
    self.assertEqual(join(), None)
                     ~~~~^^
  File "/home/stan/buildarea/3.x.stan-raspbian.nondebug/build/Lib/test/_test_multiprocessing.py", line 250, in __call__
    return self.func(*args, **kwds)
           ~~~~~~~~~^^^^^^^^^^^^^^^
  File "/home/stan/buildarea/3.x.stan-raspbian.nondebug/build/Lib/multiprocessing/process.py", line 156, in join
    res = self._popen.wait(timeout)
  File "/home/stan/buildarea/3.x.stan-raspbian.nondebug/build/Lib/multiprocessing/popen_fork.py", line 44, in wait
    return self.poll(os.WNOHANG if timeout == 0.0 else 0)
           ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stan/buildarea/3.x.stan-raspbian.nondebug/build/Lib/multiprocessing/popen_fork.py", line 28, in poll
    pid, sts = os.waitpid(self.pid, flag)
               ~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "/home/stan/buildarea/3.x.stan-raspbian.nondebug/build/Lib/test/_test_multiprocessing.py", line 573, in handler
    raise RuntimeError('join took too long: %s' % p)
RuntimeError: join took too long: <Process name='Process-151' pid=210285 parent=209827 started daemon>

lkollar pushed a commit to lkollar/cpython that referenced this pull request Sep 9, 2025
pythonGH-133662)

Remove deprecated `zipimport.zipimporter.load_module`.
@Wulian233 Wulian233 deleted the zipimporter branch September 27, 2025 23:41
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.

7 participants