Skip to content

Commit 3e4a3dd

Browse files
Krzysztof ChomskiTomAugspurger
Krzysztof Chomski
authored andcommitted
BUG: fillna maximum recursion depth exceeded in cmp (GH18159). (#18385)
(cherry picked from commit 27a64b2)
1 parent 1e81abb commit 3e4a3dd

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
@@ -1837,8 +1837,10 @@ def _can_hold_element(self, element):
18371837
if tipo is not None:
18381838
return (issubclass(tipo.type, (np.floating, np.integer)) and
18391839
not issubclass(tipo.type, (np.datetime64, np.timedelta64)))
1840-
return (isinstance(element, (float, int, np.floating, np.int_)) and
1841-
not isinstance(element, (bool, np.bool_, datetime, timedelta,
1840+
return (
1841+
isinstance(
1842+
element, (float, int, np.floating, np.int_, compat.long))
1843+
and not isinstance(element, (bool, np.bool_, datetime, timedelta,
18421844
np.datetime64, np.timedelta64)))
18431845

18441846
def to_native_types(self, slicer=None, na_rep='', float_format=None,
@@ -1886,9 +1888,11 @@ def _can_hold_element(self, element):
18861888
if tipo is not None:
18871889
return issubclass(tipo.type,
18881890
(np.floating, np.integer, np.complexfloating))
1889-
return (isinstance(element,
1890-
(float, int, complex, np.float_, np.int_)) and
1891-
not isinstance(element, (bool, np.bool_)))
1891+
return (
1892+
isinstance(
1893+
element,
1894+
(float, int, complex, np.float_, np.int_, compat.long))
1895+
and not isinstance(element, (bool, np.bool_)))
18921896

18931897
def should_store(self, value):
18941898
return issubclass(value.dtype.type, np.complexfloating)

pandas/tests/internals/test_internals.py

+2
Original file line numberDiff line numberDiff line change
@@ -1245,7 +1245,9 @@ class TestCanHoldElement(object):
12451245
@pytest.mark.parametrize('value, dtype', [
12461246
(1, 'i8'),
12471247
(1.0, 'f8'),
1248+
(2**63, 'f8'),
12481249
(1j, 'complex128'),
1250+
(2**63, 'complex128'),
12491251
(True, 'bool'),
12501252
(np.timedelta64(20, 'ns'), '<m8[ns]'),
12511253
(np.datetime64(20, 'ns'), '<M8[ns]'),

0 commit comments

Comments
 (0)