Closed
Description
Checklist
- I am confident this is a bug in CPython, not a bug in a third-party project
- I have searched the CPython issue tracker,
and am confident this bug has not been reported before
CPython versions tested on:
3.10
Operating systems tested on:
Linux
Output from running 'python -VV' on the command line:
Python 3.10.12 (main, Jul 5 2023, 18:54:27) [GCC 11.2.0]
A clear and concise description of the bug:
The code for set_forkserver_preload
(also in the latest main
branch) should check the type of the elements passed through the module_names
parameter, but instead checks the elements of self._preload_modules
.
Code for reproducing:
#!/usr/bin/env python3
import multiprocessing as mp
import time
def work(param):
print("work")
if __name__ == '__main__':
ctx = mp.get_context('forkserver')
ctx.set_forkserver_preload(['time', 1])
with ctx.Pool(2) as p:
p.map(work, [0, 1, 2, 3 ])
Raises error:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File ".../lib/python3.10/multiprocessing/forkserver.py", line 178, in main
__import__(modname)
TypeError: __import__() argument 1 must be str, not int