Skip to content

gh-145376: Fix refleak and null pointer deref in unusual error path of datetime module#145476

Open
eendebakpt wants to merge 3 commits intopython:mainfrom
eendebakpt:refleak_datetime
Open

gh-145376: Fix refleak and null pointer deref in unusual error path of datetime module#145476
eendebakpt wants to merge 3 commits intopython:mainfrom
eendebakpt:refleak_datetime

Conversation

@eendebakpt
Copy link
Contributor

@eendebakpt eendebakpt commented Mar 3, 2026

Copy link
Member

@StanFromIreland StanFromIreland left a comment

Choose a reason for hiding this comment

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

I think this should get a news entry.

@eendebakpt
Copy link
Contributor Author

I think this should get a news entry.

Added the news entry, although I think we can skip it since the changes are only in very rare paths.

@encukou
Copy link
Member

encukou commented Mar 4, 2026

I think we can skip [a news entry] since the changes are only in very rare paths.

That's my assesment too. It's technically a user-visible change, but that user needs to squint really hard.

Comment on lines 6911 to 6912
PyErr_Format(PyExc_TypeError, "utcoffset() returned %.200s,"
" expected timedelta or None", Py_TYPE(offset)->tp_name);
Copy link
Member

Choose a reason for hiding this comment

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

While we are here, you can use %T which is safer and provides more accurate representation:

Suggested change
PyErr_Format(PyExc_TypeError, "utcoffset() returned %.200s,"
" expected timedelta or None", Py_TYPE(offset)->tp_name);
PyErr_Format(PyExc_TypeError, "utcoffset() returned %T,"
" expected timedelta or None", offset);

@@ -0,0 +1 @@
Fix refleak and null pointer deref in unusual error path of :mod:`datetime`.
Copy link
Member

Choose a reason for hiding this comment

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

Please remove it, users should not be impacted by this change. The error case is very unlikely.

Sign up for free to 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.

5 participants