-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BUG: underflow on Timestamp creation #14433
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,11 @@ from cpython cimport ( | |
PyUnicode_AsUTF8String, | ||
) | ||
|
||
|
||
cdef extern from "headers/stdint.h": | ||
enum: INT64_MAX | ||
enum: INT64_MIN | ||
|
||
# Cython < 0.17 doesn't have this in cpython | ||
cdef extern from "Python.h": | ||
cdef PyTypeObject *Py_TYPE(object) | ||
|
@@ -904,10 +909,9 @@ cpdef object get_value_box(ndarray arr, object loc): | |
|
||
|
||
# Add the min and max fields at the class level | ||
# These are defined as magic numbers due to strange | ||
# wraparound behavior when using the true int64 lower boundary | ||
cdef int64_t _NS_LOWER_BOUND = -9223285636854775000LL | ||
cdef int64_t _NS_UPPER_BOUND = 9223372036854775807LL | ||
# INT64_MIN is reserved for NaT | ||
cdef int64_t _NS_LOWER_BOUND = INT64_MIN + 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why change this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The old lower bound was higher than it needed to be, because of this issue; although we didn't actually enforce it everywhere. Upper bound is the same. I can go back to hardcoded numbers, just thought the defined constants were clearer - I assumed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's fine There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On further look, I'll change the lower bound back - in our compat with python datetime we assume in several places that the min value has a 0 nanosecond unit - I think it could be worked around, but fairly invasive for another 800 ns of span. |
||
cdef int64_t _NS_UPPER_BOUND = INT64_MAX | ||
|
||
cdef pandas_datetimestruct _NS_MIN_DTS, _NS_MAX_DTS | ||
pandas_datetime_to_datetimestruct(_NS_LOWER_BOUND, PANDAS_FR_ns, &_NS_MIN_DTS) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't these be imported from the numpy headers? for consistency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is how we do it in
lib.pyx
, but agreed it probably makes more sense to pull it from the numpy headers.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok no big deal
ideally should be consistent across the code
maybe just import into util.pxd and use from there?