Skip to content

Commit

Permalink
BUG: iter with readonly values, closes pandas-dev#28055
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrockmendel committed Aug 21, 2019
1 parent 8b3246f commit 318bdfc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pandas/_libs/tslib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ cdef inline object create_time_from_ts(

@cython.wraparound(False)
@cython.boundscheck(False)
def ints_to_pydatetime(int64_t[:] arr, object tz=None, object freq=None,
def ints_to_pydatetime(const int64_t[:] arr, object tz=None, object freq=None,
str box="datetime"):
"""
Convert an i8 repr to an ndarray of datetimes, date, time or Timestamp
Expand Down
8 changes: 8 additions & 0 deletions pandas/tests/indexes/datetimes/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,3 +377,11 @@ def test_nanosecond_field(self):
dti = DatetimeIndex(np.arange(10))

tm.assert_index_equal(dti.nanosecond, pd.Index(np.arange(10, dtype=np.int64)))


def test_iter_readonly():
# GH#28055 ints_to_pydatetime with readonly array
arr = np.array([np.datetime64("2012-02-15T12:00:00.000000000")])
arr.setflags(write=False)
dti = pd.to_datetime(arr)
list(dti)

0 comments on commit 318bdfc

Please sign in to comment.