Skip to content

Conversation

@gvanrossum
Copy link
Member

@gvanrossumgvanrossum commented Sep 29, 2022

@gvanrossum
Copy link
MemberAuthor

@xiaxinmeng Feel free to add your review.

Copy link
Contributor

@kumaraditya303kumaraditya303 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines +844 to +848
classevil:
def__eq__(self, other):
fut.remove_done_callback(other)

fut.remove_done_callback(evil())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Class names should normally use the CapWords convention.

Suggested change
classevil:
def__eq__(self, other):
fut.remove_done_callback(other)
fut.remove_done_callback(evil())
classEvil:
def__eq__(self, other):
fut.remove_done_callback(other)
fut.remove_done_callback(Evil())

def__eq__(self, other):
fut.remove_done_callback(other)

fut.remove_done_callback(evil())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All callbacks added by fut.add_done_callback() will be cleared when calling fut.remove_done_callback(Evil()), but the return value will be the number of callbacks added last.

I'm not sure if we need to improve the return value of remove done callback further, the current changes are good enough to fix the crash. :)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
@gvanrossumgvanrossum merged commit 63780f4 into python:mainSep 30, 2022
@miss-islington
Copy link
Contributor

Thanks @gvanrossum for the PR 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11.
🐍🍒⛏🤖

@gvanrossumgvanrossum deleted the fix-fut-callbacks branch September 30, 2022 19:57
@bedevere-bot
Copy link

GH-97692 is a backport of this pull request to the 3.11 branch.

@bedevere-botbedevere-bot removed the needs backport to 3.11 only security fixes label Sep 30, 2022
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 30, 2022
…ythonGH-97660) Evil code could cause fut_callbacks to be cleared when PyObject_RichCompareBool is called. (cherry picked from commit 63780f4) Co-authored-by: Guido van Rossum <guido@python.org>
@bedevere-bot
Copy link

GH-97693 is a backport of this pull request to the 3.10 branch.

@bedevere-botbedevere-bot removed the needs backport to 3.10 only security fixes label Sep 30, 2022
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 30, 2022
…ythonGH-97660) Evil code could cause fut_callbacks to be cleared when PyObject_RichCompareBool is called. (cherry picked from commit 63780f4) Co-authored-by: Guido van Rossum <guido@python.org>
miss-islington added a commit that referenced this pull request Sep 30, 2022
) Evil code could cause fut_callbacks to be cleared when PyObject_RichCompareBool is called. (cherry picked from commit 63780f4) Co-authored-by: Guido van Rossum <guido@python.org>
miss-islington added a commit that referenced this pull request Sep 30, 2022
) Evil code could cause fut_callbacks to be cleared when PyObject_RichCompareBool is called. (cherry picked from commit 63780f4) Co-authored-by: Guido van Rossum <guido@python.org>
serhiy-storchaka pushed a commit to serhiy-storchaka/cpython that referenced this pull request Oct 2, 2022
…ython#97660) Evil code could cause fut_callbacks to be cleared when PyObject_RichCompareBool is called.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@gvanrossum@miss-islington@bedevere-bot@JelleZijlstra@kumaraditya303@CharlieZhao95