diff --git a/RELEASE.rst b/RELEASE.rst index 31ded56bb9263..9ea69d24b8139 100644 --- a/RELEASE.rst +++ b/RELEASE.rst @@ -85,6 +85,7 @@ pandas 0.8.2 - Support StaticTzInfo in DatetimeIndex infrastructure (#1692) - Allow MultiIndex setops with length-0 other type indexes (#1727) - Fix handling of DatetimeIndex in DataFrame.to_records (#1720) + - Fix handling of general objects in isnull on which bool(...) fails (#1749) pandas 0.8.1 ============ diff --git a/pandas/src/util.pxd b/pandas/src/util.pxd index 694fd9202f1e2..f25f7b55c92da 100644 --- a/pandas/src/util.pxd +++ b/pandas/src/util.pxd @@ -58,7 +58,10 @@ cdef inline is_array(object o): cdef inline bint _checknull(object val): - return not cnp.PyArray_Check(val) and (val is None or val != val) + try: + return bool(val is None or val != val) + except ValueError: + return False cdef inline bint _checknan(object val): return not cnp.PyArray_Check(val) and val != val diff --git a/pandas/tests/test_series.py b/pandas/tests/test_series.py index daefbd7456a27..26f6a5f2e1e98 100644 --- a/pandas/tests/test_series.py +++ b/pandas/tests/test_series.py @@ -1020,6 +1020,17 @@ def test_repr(self): rep_str = repr(ser) self.assert_("Name: 0" in rep_str) + def test_repr_bool_fails(self): + s = Series([DataFrame(np.random.randn(2,2)) for i in range(5)]) + + import sys + + buf = StringIO() + sys.stderr = buf + # it works (with no Cython exception barf)! + repr(s) + sys.stderr = sys.__stderr__ + self.assertEquals(buf.getvalue(), '') def test_timeseries_repr_object_dtype(self): index = Index([datetime(2000, 1, 1) + timedelta(i)