gh-145242: Add early validation for target in Thread and Process#145243
gh-145242: Add early validation for target in Thread and Process#145243gourijain029-del wants to merge 2 commits into
Conversation
| @@ -0,0 +1 @@ | |||
| Fix a segmentation fault in :func:`unicodedata.iter_graphemes` when the iterator is deallocated after being cleared by the garbage collector. | |||
There was a problem hiding this comment.
You have unrelated changes on this branch.
picnixz
left a comment
There was a problem hiding this comment.
Please revert unrelated changes.
|
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 |
|
This PR is stale because it has been open for 30 days with no activity. |
his PR adds early validation for the
target
argument in the constructors of threading.Thread and multiprocessing.Process.
Changes
Early Validation: The
target
argument is now checked for callability within
init
. If a non-callable
target
is provided (and it is not
None
), a TypeError is raised immediately in the calling thread.
Improved Tracebacks: Previously, the validation would only fail deep within the library's internal
_bootstrap
or
start()
logic. By moving this check to the constructor, the resulting traceback now clearly points to the line where the
Thread
or
Process
object was instantiated, making it significantly easier for users to debug.
Group Argument Validation: Replaced internal assert group is None statements with explicit TypeError raises. This ensures consistent error reporting even when Python is run with optimizations (-O).
Unit Tests: Added
test_invalid_args
to both test_threading and test_multiprocessing to ensure correct behavior and prevent regressions.
targettoThread(...).start()does not include the line calling thestart()method #145242