Title: gh-118331: Don't raise an error if tuple allocation fails when clearing weakrefs by mpage · Pull Request #118338 · python/cpython · GitHub
Open Graph Title: gh-118331: Don't raise an error if tuple allocation fails when clearing weakrefs by mpage · Pull Request #118338 · python/cpython
X Title: gh-118331: Don't raise an error if tuple allocation fails when clearing weakrefs by mpage · Pull Request #118338 · python/cpython
Description: It's not safe to raise an exception in PyObject_ClearWeakRefs() if one is not already set. PyObject_ClearWeakRefs() may be called (transitively) by _Py_Dealloc(), which contains cpython/Objects/object.c Lines 2843 to 2860 in 5a90de0 // gh-89373: The tp_dealloc function must leave the current exception // unchanged. if (tstate != NULL && tstate->current_exception != old_exc) { const char *err; if (old_exc == NULL) { err = "Deallocator of type '%s' raised an exception"; } else if (tstate->current_exception == NULL) { err = "Deallocator of type '%s' cleared the current exception"; } else { // It can happen if dealloc() normalized the current exception. // A deallocator function must not change the current exception, // not even normalize it. err = "Deallocator of type '%s' overrode the current exception"; } _Py_FatalErrorFormat(__func__, err, type->tp_name); } Additionally, make sure we clear the weakrefs when tuple allocation fails. This bug predates gh-111926. It exists in 3.12 and likely in earlier versions too. If it's getting tickled now, I suspect it's because we always allocate a tuple now when clearing weakrefs that have callbacks, whereas previously we only did so if there was more than one weakref with a callback, making it more likely that we fail to allocate a tuple when running test_repl.TestInteractiveInterpreter.test_no_memory. Issue: gh-118331
Open Graph Description: It's not safe to raise an exception in PyObject_ClearWeakRefs() if one is not already set. PyObject_ClearWeakRefs() may be called (transitively) by _Py_Dealloc(), which contains ...
X Description: It's not safe to raise an exception in PyObject_ClearWeakRefs() if one is not already set. PyObject_ClearWeakRefs() may be called (transitively) by _Py_Dealloc(), which contains ...
Opengraph URL: https://github.com/python/cpython/pull/118338
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/commits/:range(.:format) |
| route-controller | pull_requests |
| route-action | commits |
| fetch-nonce | v2:01ae8928-9702-d13d-9d4c-ddd887cfc33b |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 9032:B0C39:148EACB:1B1E8E9:69968739 |
| html-safe-nonce | f53b0dcbb01d4b1bff35e2aa135fb132e0ef9882774e7e4ac3a3a0dfa83d740e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MDMyOkIwQzM5OjE0OEVBQ0I6MUIxRThFOTo2OTk2ODczOSIsInZpc2l0b3JfaWQiOiIxOTUzOTIwNjc1MDE1NDYwNjY1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 24165010eb386d063d781de9c4e565b0caaf10171877690b39d3ae514f303120 |
| hovercard-subject-tag | pull_request:1843615158 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/python/cpython/pull/118338/commits/632087c085e0f571a435501e03ed294675f36eb6 |
| twitter:image | https://avatars.githubusercontent.com/u/577841?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/577841?s=400&v=4 |
| og:image:alt | It's not safe to raise an exception in PyObject_ClearWeakRefs() if one is not already set. PyObject_ClearWeakRefs() may be called (transitively) by _Py_Dealloc(), which contains ... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5513290f8d09a9ed78de519ab8316ed23b2b0ddd5e91d2420df56691d00827e8 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | aec344f4c0373b43d84a8d2e31ea006da714f08f |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width