Skip to content

Commit 27a64b2

Browse files
Krzysztof Chomskijreback
Krzysztof Chomski
authored andcommitted
BUG: fillna maximum recursion depth exceeded in cmp (GH18159). (pandas-dev#18385)
1 parent 288bf6e commit 27a64b2

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

doc/source/whatsnew/v0.21.1.txt

+3
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ Documentation Changes
8585

8686
Bug Fixes
8787
~~~~~~~~~
88+
-
89+
8890

8991
Conversion
9092
^^^^^^^^^^
@@ -94,6 +96,7 @@ Conversion
9496
- Bug in :meth:`IntervalIndex.copy` when copying and ``IntervalIndex`` with non-default ``closed`` (:issue:`18339`)
9597
- Bug in :func:`DataFrame.to_dict` where columns of datetime that are tz-aware were not converted to required arrays when used with ``orient='records'``, raising``TypeError` (:issue:`18372`)
9698
- Bug in :class:`DateTimeIndex` and :meth:`date_range` where mismatching tz-aware ``start`` and ``end`` timezones would not raise an err if ``end.tzinfo`` is None (:issue:`18431`)
99+
- Bug in :meth:`Series.fillna` which raised when passed a long integer on Python 2 (:issue:`18159`).
97100
-
98101

99102
Indexing

pandas/core/internals.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -1847,8 +1847,10 @@ def _can_hold_element(self, element):
18471847
if tipo is not None:
18481848
return (issubclass(tipo.type, (np.floating, np.integer)) and
18491849
not issubclass(tipo.type, (np.datetime64, np.timedelta64)))
1850-
return (isinstance(element, (float, int, np.floating, np.int_)) and
1851-
not isinstance(element, (bool, np.bool_, datetime, timedelta,
1850+
return (
1851+
isinstance(
1852+
element, (float, int, np.floating, np.int_, compat.long))
1853+
and not isinstance(element, (bool, np.bool_, datetime, timedelta,
18521854
np.datetime64, np.timedelta64)))
18531855

18541856
def to_native_types(self, slicer=None, na_rep='', float_format=None,
@@ -1896,9 +1898,11 @@ def _can_hold_element(self, element):
18961898
if tipo is not None:
18971899
return issubclass(tipo.type,
18981900
(np.floating, np.integer, np.complexfloating))
1899-
return (isinstance(element,
1900-
(float, int, complex, np.float_, np.int_)) and
1901-
not isinstance(element, (bool, np.bool_)))
1901+
return (
1902+
isinstance(
1903+
element,
1904+
(float, int, complex, np.float_, np.int_, compat.long))
1905+
and not isinstance(element, (bool, np.bool_)))
19021906

19031907
def should_store(self, value):
19041908
return issubclass(value.dtype.type, np.complexfloating)

pandas/tests/internals/test_internals.py

+2
Original file line numberDiff line numberDiff line change
@@ -1222,7 +1222,9 @@ class TestCanHoldElement(object):
12221222
@pytest.mark.parametrize('value, dtype', [
12231223
(1, 'i8'),
12241224
(1.0, 'f8'),
1225+
(2**63, 'f8'),
12251226
(1j, 'complex128'),
1227+
(2**63, 'complex128'),
12261228
(True, 'bool'),
12271229
(np.timedelta64(20, 'ns'), '<m8[ns]'),
12281230
(np.datetime64(20, 'ns'), '<M8[ns]'),

0 commit comments

Comments
 (0)