Skip to content

gh-151039: Fix a crash when datetime.timedelta outlives _datetime module#151044

Open
sobolevn wants to merge 2 commits into
python:mainfrom
sobolevn:issue-151039
Open

gh-151039: Fix a crash when datetime.timedelta outlives _datetime module#151044
sobolevn wants to merge 2 commits into
python:mainfrom
sobolevn:issue-151039

Conversation

@sobolevn
Copy link
Copy Markdown
Member

@sobolevn sobolevn commented Jun 7, 2026

Several changes:

  1. Always check that GET_CURRENT_STATE can return NULL
  2. Unwrap (void)PyWeakref_GetRef call into a full check for safety, there are multiple things that can go wrong when getting a weakref
  3. Remove assert(!PyErr_Occurred()); followed by if (PyErr_Occurred()) {

@sobolevn sobolevn requested a review from picnixz June 7, 2026 14:33
@sobolevn sobolevn added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Jun 7, 2026
@sobolevn
Copy link
Copy Markdown
Member Author

sobolevn commented Jun 7, 2026

Ok, I just discovered #132413 which is related.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant