Skip to content

Commit 8837a71

Browse files
committed
Another debug
1 parent ff20a1d commit 8837a71

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

pandas/_libs/tslibs/timedeltas.pxd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ cpdef int64_t delta_to_nanoseconds(
1010
delta, NPY_DATETIMEUNIT reso=*, bint round_ok=*
1111
) except? -1
1212
cpdef int64_t debug_divmod_bug(delta) except? -1
13+
cpdef timedelta debug_2()
1314
cdef convert_to_timedelta64(object ts, str unit)
1415
cdef bint is_any_td_scalar(object obj)
1516

pandas/_libs/tslibs/timedeltas.pyx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,14 @@ def ints_to_pytimedelta(ndarray m8values, box=False):
233233
# ----------------------------------------------------------------------
234234

235235

236+
cpdef timedelta debug_2():
237+
cdef int64_t val = -420000000000
238+
us, remainder = divmod(val, 1000)
239+
if remainder >= 500:
240+
us += 1
241+
return timedelta(microseconds=us)
242+
243+
236244
cpdef int64_t debug_divmod_bug(delta) except? -1:
237245
cdef int64_t n, div, mod, conv = 1000 * 1
238246
if PyDelta_Check(delta):

pandas/tests/test_debug.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
from pandas._libs.tslibs.timedeltas import debug_divmod_bug
1+
from pandas._libs.tslibs.timedeltas import (
2+
debug_2,
3+
debug_divmod_bug,
4+
)
25

36
import pandas as pd
47

@@ -19,3 +22,7 @@ def test_debug_divmod_bug():
1922
result = debug_divmod_bug(td)
2023
expected = non_buggy_divmod(td)
2124
assert result == expected
25+
26+
27+
def test_debug_2():
28+
assert False, debug_2()

0 commit comments

Comments
 (0)