From cdb67f09720c818b13b13dd35dc7e1bc984bb44e Mon Sep 17 00:00:00 2001 From: "Gregory P. Smith" Date: Tue, 28 Jan 2025 01:50:45 -0800 Subject: [PATCH] include the timestamp in exception pickles. --- Objects/exceptions.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Objects/exceptions.c b/Objects/exceptions.c index a662055d37fcf2..62c7427919af35 100644 --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -213,10 +213,22 @@ static PyObject * BaseException___reduce___impl(PyBaseExceptionObject *self) /*[clinic end generated code: output=af87c1247ef98748 input=283be5a10d9c964f]*/ { - if (self->args && self->dict) + if (!self->dict) { + self->dict = PyDict_New(); + } + if (self->args && self->dict) { + PyObject *ts = PyLong_FromLongLong(self->timestamp_ns); + if (!ts) + return NULL; + if (PyDict_SetItemString(self->dict, "__timestamp_ns__", ts) == -1) { + Py_DECREF(ts); + return NULL; + } + Py_DECREF(ts); return PyTuple_Pack(3, Py_TYPE(self), self->args, self->dict); - else + } else { return PyTuple_Pack(2, Py_TYPE(self), self->args); + } } /*