We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f30c74d commit 85496cfCopy full SHA for 85496cf
1 file changed
Objects/exceptions.c
@@ -222,10 +222,13 @@ BaseException_repr(PyBaseExceptionObject *self)
222
223
/* Returns dict on success, after having added a __timestamp_ns__ key; NULL
224
otherwise. dict does not have to be self->dict as the getstate use case
225
- often uses a copy. */
+ often uses a copy. No key is added if its value would be 0. */
226
static PyObject* BaseException_add_timestamp_to_dict(PyBaseExceptionObject *self, PyObject *dict)
227
{
228
assert(dict != NULL);
229
+ if (self->timestamp_ns <= 0) {
230
+ return dict;
231
+ }
232
PyObject *ts = PyLong_FromLongLong(self->timestamp_ns);
233
if (!ts)
234
return NULL;
0 commit comments