mirror of
https://github.com/python/cpython.git
synced 2024-11-24 18:34:43 +08:00
gh-107963: Fix set_forkserver_preload to check the type of given list (#107965)
gh-107963: Fix set_forkserver_preload to check the type of given list
This commit is contained in:
parent
d66bc9e8a7
commit
6515ec3d3d
@ -61,7 +61,7 @@ class ForkServer(object):
|
||||
|
||||
def set_forkserver_preload(self, modules_names):
|
||||
'''Set list of module names to try to load in forkserver process.'''
|
||||
if not all(type(mod) is str for mod in self._preload_modules):
|
||||
if not all(type(mod) is str for mod in modules_names):
|
||||
raise TypeError('module_names must be a list of strings')
|
||||
self._preload_modules = modules_names
|
||||
|
||||
|
@ -5369,6 +5369,14 @@ class TestStartMethod(unittest.TestCase):
|
||||
self.assertRaises(ValueError, ctx.set_start_method, None)
|
||||
self.check_context(ctx)
|
||||
|
||||
def test_context_check_module_types(self):
|
||||
try:
|
||||
ctx = multiprocessing.get_context('forkserver')
|
||||
except ValueError:
|
||||
raise unittest.SkipTest('forkserver should be available')
|
||||
with self.assertRaisesRegex(TypeError, 'module_names must be a list of strings'):
|
||||
ctx.set_forkserver_preload([1, 2, 3])
|
||||
|
||||
def test_set_get(self):
|
||||
multiprocessing.set_forkserver_preload(PRELOAD)
|
||||
count = 0
|
||||
|
@ -0,0 +1,2 @@
|
||||
Fix :func:`multiprocessing.set_forkserver_preload` to check the given list
|
||||
of modules names. Patch by Dong-hee Na.
|
Loading…
Reference in New Issue
Block a user