Skip to content

Commit eb6e479

Browse files
committed
comment zero_delta due to weird bug
1 parent 33f382f commit eb6e479

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

Lib/test/datetimetester.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,11 @@ def test_constructor(self):
554554
ra(TypeError, lambda: td(milliseconds='1'))
555555
ra(TypeError, lambda: td(microseconds='1'))
556556

557+
def test_zero_delta(self):
558+
td = timedelta
559+
ns = td(nanoseconds=1)
560+
assert ns/3 != ns, f"{ns/3 =} should not be equal to {ns =}"
561+
557562
def test_computations(self):
558563
if self.is_fast_test(): return # BUG
559564
eq = self.assertEqual

Modules/_datetimemodule.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,10 +1437,11 @@ new_delta_ex(int days, int seconds, int microseconds, int nanoseconds, int norma
14371437
if (check_delta_day_range(days) < 0)
14381438
return NULL;
14391439

1440+
// FIX: gives zero_delta.nanoseconds = 1; how?
14401441
self = look_up_delta(days, seconds, microseconds, nanoseconds, type);
1441-
if (self != NULL) {
1442-
return (PyObject *)self;
1443-
}
1442+
// if (self != NULL) {
1443+
// return (PyObject *)self;
1444+
// }
14441445
assert(!PyErr_Occurred());
14451446

14461447
self = (PyDateTime_Delta *) (type->tp_alloc(type, 0));

0 commit comments

Comments
 (0)