Skip to content

Commit cdb67f0

Browse files
committed
include the timestamp in exception pickles.
1 parent a05766f commit cdb67f0

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

Objects/exceptions.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,22 @@ static PyObject *
213213
BaseException___reduce___impl(PyBaseExceptionObject *self)
214214
/*[clinic end generated code: output=af87c1247ef98748 input=283be5a10d9c964f]*/
215215
{
216-
if (self->args && self->dict)
216+
if (!self->dict) {
217+
self->dict = PyDict_New();
218+
}
219+
if (self->args && self->dict) {
220+
PyObject *ts = PyLong_FromLongLong(self->timestamp_ns);
221+
if (!ts)
222+
return NULL;
223+
if (PyDict_SetItemString(self->dict, "__timestamp_ns__", ts) == -1) {
224+
Py_DECREF(ts);
225+
return NULL;
226+
}
227+
Py_DECREF(ts);
217228
return PyTuple_Pack(3, Py_TYPE(self), self->args, self->dict);
218-
else
229+
} else {
219230
return PyTuple_Pack(2, Py_TYPE(self), self->args);
231+
}
220232
}
221233

222234
/*

0 commit comments

Comments
 (0)