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

gh-118331: Don't raise an error if tuple allocation fails when clearing weakrefs #118338

Merged
merged 6 commits into from Apr 29, 2024

Commits on Apr 26, 2024

  1. Don't raise an error if tuple allocation fails when clearing weakrefs

    It's not safe to raise an exception in `PyObject_ClearWeakRefs()` if one
    is not already set, since it may be called by `_Py_Dealloc()` and hit
    https://github.com/python/cpython/blob/5a90de0d4cbc151a6deea36a27eb81b192410e56/Objects/object.c#L2843-L2860.
    
    Additionally, make sure we clear the weakrefs even when tuple allocation
    fails.
    
    This bug predates pythongh-111926. If it's getting tickled now, I suspect it's
    because we always allocate a tuple when clearing weakrefs that have callbacks.
    mpage committed Apr 26, 2024
    Configuration menu
    Copy the full SHA
    195a7e5 View commit details
    Browse the repository at this point in the history
  2. Fix test

    mpage committed Apr 26, 2024
    Configuration menu
    Copy the full SHA
    99e3f85 View commit details
    Browse the repository at this point in the history

Commits on Apr 27, 2024

  1. Make test more robust to future changes

    Depending on finalization, we may encounter another allocation failure
    that causes the interpreter to exit with a non-zero status. That's OK,
    we just need to verify that we're not exiting because weakref clearing
    raised an exception.
    mpage committed Apr 27, 2024
    Configuration menu
    Copy the full SHA
    632087c View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    7ba419d View commit details
    Browse the repository at this point in the history

Commits on Apr 29, 2024

  1. Don't chain exceptions

    mpage committed Apr 29, 2024
    Configuration menu
    Copy the full SHA
    15c85d4 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    728a297 View commit details
    Browse the repository at this point in the history