diff --git a/pandas/_libs/intervaltree.pxi.in b/pandas/_libs/intervaltree.pxi.in index ac713a928973f..08bfaf21db9fb 100644 --- a/pandas/_libs/intervaltree.pxi.in +++ b/pandas/_libs/intervaltree.pxi.in @@ -158,7 +158,7 @@ cdef class IntervalTree(IntervalMixin): # TODO: write get_indexer_intervals cdef: - size_t old_len + Py_ssize_t old_len Py_ssize_t i Int64Vector result @@ -179,7 +179,7 @@ cdef class IntervalTree(IntervalMixin): the given array of scalar targets. Non-unique positions are repeated. """ cdef: - size_t old_len + Py_ssize_t old_len Py_ssize_t i Int64Vector result, missing diff --git a/pandas/_libs/lib.pyx b/pandas/_libs/lib.pyx index 1c2f80b832201..36dddbb446e83 100644 --- a/pandas/_libs/lib.pyx +++ b/pandas/_libs/lib.pyx @@ -2066,7 +2066,7 @@ def maybe_convert_objects(ndarray[object] objects, bint try_float=0, floats[i] = float(val) complexes[i] = complex(val) seen.float_ = 1 - except Exception: + except (ValueError, TypeError): seen.object_ = 1 break else: @@ -2346,7 +2346,8 @@ def to_object_array_tuples(rows: object): row = rows[i] for j in range(len(row)): result[i, j] = row[j] - except Exception: + except TypeError: + # e.g. "Expected tuple, got list" # upcast any subclasses to tuple for i in range(n): row = (rows[i],) if checknull(rows[i]) else tuple(rows[i]) diff --git a/pandas/_libs/tslibs/parsing.pyx b/pandas/_libs/tslibs/parsing.pyx index 33665484311ba..bf0a0ae5a3fe9 100644 --- a/pandas/_libs/tslibs/parsing.pyx +++ b/pandas/_libs/tslibs/parsing.pyx @@ -581,7 +581,7 @@ def try_parse_dates(object[:] values, parser=None, else: result[i] = parse_date(values[i]) except Exception: - # failed + # Since parser is user-defined, we can't guess what it migh raise return values else: parse_date = parser diff --git a/pandas/_libs/tslibs/timezones.pyx b/pandas/_libs/tslibs/timezones.pyx index cbfbc14c35b35..bc1fdfae99de9 100644 --- a/pandas/_libs/tslibs/timezones.pyx +++ b/pandas/_libs/tslibs/timezones.pyx @@ -226,11 +226,8 @@ cdef object get_dst_info(object tz): if treat_tz_as_pytz(tz): trans = np.array(tz._utc_transition_times, dtype='M8[ns]') trans = trans.view('i8') - try: - if tz._utc_transition_times[0].year == 1: - trans[0] = NPY_NAT + 1 - except Exception: - pass + if tz._utc_transition_times[0].year == 1: + trans[0] = NPY_NAT + 1 deltas = unbox_utcoffsets(tz._transition_info) typ = 'pytz'