Skip to content

Commit 85496cf

Browse files
committed
WIP: no dict key for reduce when 0
1 parent f30c74d commit 85496cf

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

Objects/exceptions.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,13 @@ BaseException_repr(PyBaseExceptionObject *self)
222222

223223
/* Returns dict on success, after having added a __timestamp_ns__ key; NULL
224224
otherwise. dict does not have to be self->dict as the getstate use case
225-
often uses a copy. */
225+
often uses a copy. No key is added if its value would be 0. */
226226
static PyObject* BaseException_add_timestamp_to_dict(PyBaseExceptionObject *self, PyObject *dict)
227227
{
228228
assert(dict != NULL);
229+
if (self->timestamp_ns <= 0) {
230+
return dict;
231+
}
229232
PyObject *ts = PyLong_FromLongLong(self->timestamp_ns);
230233
if (!ts)
231234
return NULL;

0 commit comments

Comments
 (0)