fix segmentation fault when datetime module is invalid#3818
fix segmentation fault when datetime module is invalid#3818davidhewitt merged 1 commit intoPyO3:mainfrom
datetime module is invalid#3818Conversation
CodSpeed Performance ReportMerging #3818 will degrade performances by 16.95%Comparing Summary
Benchmarks breakdown
|
adamreichold
left a comment
There was a problem hiding this comment.
Two nits. Otherwise LGTM.
I guess an invalid module on the path is weird enough that this does not need an immediate backport and 0.20.x maintenance release? This module did change significantly since 0.20.x IIRC.
43080b3 to
5b11041
Compare
|
Thanks for the review 👍
Yes, I think it is a weird edge case. I think it's also very likely that this will always just crash immediately without doing any harm, so it's just ugly UX rather than dangerous. That said, I'm about to prepare a patch release for #3619, so if it's trivial to cherry-pick this I will. |
Reported downstream in pydantic/pydantic-core#1171
We aren't checking if
PyDatetime_IMPORT()succeeds, which can lead to dereference of a null pointer and a crash if the import fails.This PR fixes that crash by adding error checking. Where possible I return the error, otherwise I just panic.