gh-156062: Fix SynchronizedBase instantiation without a lock or a ctx - #156063
Open
ekanshul wants to merge 1 commit into
Open
gh-156062: Fix SynchronizedBase instantiation without a lock or a ctx#156063ekanshul wants to merge 1 commit into
ekanshul wants to merge 1 commit into
Conversation
… a ctx ``SynchronizedBase.__init__`` called ``get_context(force=True)`` when it was given neither a lock nor a context, but ``get_context()`` has never accepted a ``force`` argument (``set_start_method()`` does), so instantiating ``Synchronized``, ``SynchronizedArray`` or ``SynchronizedString`` directly raised ``TypeError``. The module-level helpers always pass a context down, which is why this went unnoticed since the contexts were introduced.
|
The following commit authors need to sign the Contributor License Agreement: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SynchronizedBase.__init__callsget_context(force=True)when it is given neither alocknor actx, butget_context()has never accepted aforceargument (set_start_method()does). So instantiatingSynchronized,SynchronizedArrayorSynchronizedStringdirectly, without a lock or a context, raised:Value(),Array()andsynchronized()always resolve a context and pass it down, which is why this went unnoticed since the line was written in b1694cf (bpo-18999). The fix mirrors whatsynchronized()does a few lines above: callget_context().The new test instantiates each of the three wrapper classes without a lock or a context and exercises the resulting lock. Without the fix all three subtests fail with the
TypeErrorabove; with it they pass under thespawnandforkserverstart methods (theforkvariants are skipped on macOS, where I ran this).Found by running pylint over the standard library (
unexpected-keyword-arg).