10000 BUG: print format fix for datetime/timedelta · numpy/numpy@730b861 · GitHub
[go: up one dir, main page]

Skip to content

Commit 730b861

Browse files
gandalf013charris
authored andcommitted
BUG: print format fix for datetime/timedelta
1 parent 418f070 commit 730b861

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

numpy/core/src/multiarray/scalartypes.c.src

Lines changed: 14 additions & 0 deletions
< 8000 /div>
Original file line numberDiff line numberDiff line change
@@ -681,8 +681,15 @@ timedeltatype_repr(PyObject *self)
681681
ret = PyUString_FromString("numpy.timedelta64('NaT'");
682682
}
683683
else {
684+
/* Can't use "%lld" in Python < 2.7, or if HAVE_LONG_LONG is not
685+
* defined */
686+
#if defined(HAVE_LONG_LONG) && (PY_VERSION_HEX >= 0x02070000)
684687
ret = PyUString_FromFormat("numpy.timedelta64(%lld",
685688
(long long)scal->obval);
689+
#else
690+
ret = PyUString_FromFormat("numpy.timedelta64(%ld",
691+
(long)scal->obval);
692+
#endif
686693
}
687694
/* The metadata unit */
688695
if (scal->obmeta.base == NPY_FR_GENERIC) {
@@ -784,8 +791,15 @@ timedeltatype_str(PyObject *self)
784791
ret = PyUString_FromString("NaT");
785792
}
786793
else {
794+
/* Can't use "%lld" in Python < 2.7, or if HAVE_LONG_LONG is not
795+
* defined */
796+
#if defined(HAVE_LONG_LONG) && (PY_VERSION_HEX >= 0x02070000)
787797
ret = PyUString_FromFormat("%lld ",
788798
(long long)(scal->obval * scal->obmeta.num));
799+
#else
800+
ret = PyUString_FromFormat("%ld ",
801+
(long)(scal->obval * scal->obmeta.num));
802+
#endif
789803
PyUString_ConcatAndDel(&ret,
790804
PyUString_FromString(basestr));
791805
}

0 commit comments

Comments
 (0)
0