Skip to content
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

Threads can fail to start #85321

Closed
BarneyStratford mannequin opened this issue Jun 28, 2020 · 2 comments
Closed

Threads can fail to start #85321

BarneyStratford mannequin opened this issue Jun 28, 2020 · 2 comments
Labels
3.10 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@BarneyStratford
Copy link
Mannequin

BarneyStratford mannequin commented Jun 28, 2020

BPO 41149
Nosy @BarneyStratford, @pablogsal
PRs
  • bpo-41149 Fix a bug in threading that causes threads to fail to start. #21201
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2021-02-02.20:24:38.552>
    created_at = <Date 2020-06-28.16:01:04.598>
    labels = ['type-bug', 'library', '3.10']
    title = 'Threads can fail to start'
    updated_at = <Date 2021-02-02.20:24:38.551>
    user = 'https://github.com/BarneyStratford'

    bugs.python.org fields:

    activity = <Date 2021-02-02.20:24:38.551>
    actor = 'pablogsal'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-02-02.20:24:38.552>
    closer = 'pablogsal'
    components = ['Library (Lib)']
    creation = <Date 2020-06-28.16:01:04.598>
    creator = 'Barney Stratford'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 41149
    keywords = ['patch']
    message_count = 2.0
    messages = ['372521', '386169']
    nosy_count = 3.0
    nosy_names = ['python-dev', 'Barney Stratford', 'pablogsal']
    pr_nums = ['21201']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue41149'
    versions = ['Python 3.10']

    @BarneyStratford
    Copy link
    Mannequin Author

    BarneyStratford mannequin commented Jun 28, 2020

    >>> import threading
    >>> class foo (object):
    ...     def __bool__ (self):
    ...         return False
    ...     def __call__ (self):
    ...         print ("Running")
    ...
    >>> threading.Thread (target = foo ()).start ()

    The expected result of these commands would be for the thread to print
    "Running". However, in actual fact it prints nothing at all. This is
    because threading.Thread.run only runs the target if it is True as a
    boolean. This is presumably to make the thread do nothing at all if
    the target is None. In this case, I have a legitimate target that is
    False as a boolean.

    I propose to remove the test altogether. The effect of this is that
    failure to set the target of the thread, or setting a non-callable
    target, will cause the thread to raise a TypeError as soon as it is
    started. Forgetting to set the target is in almost every case a bug,
    and bugs should never be silent.

    PR to follow.

    @BarneyStratford BarneyStratford mannequin added 3.10 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Jun 28, 2020
    @pablogsal
    Copy link
    Member

    New changeset 01c4fdd by BarneyStratford in branch 'master':
    bpo-41149: Fix a bug in threading that causes fals-y threads callables to fail to start. (GH-21201)
    01c4fdd

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.10 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant