Skip to content

set_forkserver_preload should check type of elements in passed list #107963

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

Closed
2 tasks done
mawi2017 opened this issue Aug 15, 2023 · 1 comment
Closed
2 tasks done

set_forkserver_preload should check type of elements in passed list #107963

mawi2017 opened this issue Aug 15, 2023 · 1 comment
Labels
3.11 only security fixes 3.12 only security fixes 3.13 bugs and security fixes type-bug An unexpected behavior, bug, or error

Comments

@mawi2017
Copy link

mawi2017 commented Aug 15, 2023

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

Linked PRs

@mawi2017 mawi2017 added the type-bug An unexpected behavior, bug, or error label Aug 15, 2023
corona10 added a commit to corona10/cpython that referenced this issue Aug 15, 2023
corona10 added a commit to corona10/cpython that referenced this issue Aug 15, 2023
corona10 added a commit to corona10/cpython that referenced this issue Aug 15, 2023
@corona10 corona10 added 3.11 only security fixes 3.12 only security fixes 3.13 bugs and security fixes labels Aug 15, 2023
Yhg1s pushed a commit that referenced this issue Aug 15, 2023
…#107965)

gh-107963: Fix set_forkserver_preload to check the type of given list
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Aug 15, 2023
…n list (pythonGH-107965)

(cherry picked from commit 6515ec3)

Co-authored-by: Dong-hee Na <[email protected]>
pythongh-107963: Fix set_forkserver_preload to check the type of given list
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Aug 15, 2023
…n list (pythonGH-107965)

(cherry picked from commit 6515ec3)

Co-authored-by: Dong-hee Na <[email protected]>
pythongh-107963: Fix set_forkserver_preload to check the type of given list
corona10 added a commit that referenced this issue Aug 15, 2023
…en list (GH-107965) (gh-107976)

gh-107963: Fix set_forkserver_preload to check the type of given list (GH-107965)
(cherry picked from commit 6515ec3)


gh-107963: Fix set_forkserver_preload to check the type of given list

Co-authored-by: Dong-hee Na <[email protected]>
Yhg1s pushed a commit that referenced this issue Aug 15, 2023
…en list (GH-107965) (#107975)

gh-107963: Fix set_forkserver_preload to check the type of given list (GH-107965)
(cherry picked from commit 6515ec3)


gh-107963: Fix set_forkserver_preload to check the type of given list

Co-authored-by: Dong-hee Na <[email protected]>
@corona10
Copy link
Member

@mawi2017 Thank you for the report! It is now fixed for Python 3.11+

iritkatriel pushed a commit to iritkatriel/cpython that referenced this issue Aug 16, 2023
…n list (python#107965)

pythongh-107963: Fix set_forkserver_preload to check the type of given list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.11 only security fixes 3.12 only security fixes 3.13 bugs and security fixes type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants