Skip to content

Commit

Permalink
COMPAT: cython str-to-int can raise a ValueError on non-CPython (pand…
Browse files Browse the repository at this point in the history
  • Loading branch information
mattip authored and jreback committed May 31, 2017
1 parent e437ad5 commit 58f4454
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions pandas/_libs/index.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ cdef class IndexEngine:

try:
return self.mapping.get_item(val)
except TypeError:
except (TypeError, ValueError):
raise KeyError(val)

cdef inline _get_loc_duplicates(self, object val):
Expand Down Expand Up @@ -470,7 +470,7 @@ cdef class DatetimeEngine(Int64Engine):
try:
val = _to_i8(val)
return self.mapping.get_item(val)
except TypeError:
except (TypeError, ValueError):
self._date_check_type(val)
raise KeyError(val)

Expand Down
2 changes: 1 addition & 1 deletion pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -1918,7 +1918,7 @@ def get_value(self, index, col, takeable=False):

try:
return engine.get_value(series._values, index)
except TypeError:
except (TypeError, ValueError):

# we cannot handle direct indexing
# use positional
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1590,7 +1590,7 @@ def __contains__(self, key):
hash(key)
try:
return key in self._engine
except TypeError:
except (TypeError, ValueError):
return False

_index_shared_docs['contains'] = """
Expand All @@ -1610,7 +1610,7 @@ def contains(self, key):
hash(key)
try:
return key in self._engine
except TypeError:
except (TypeError, ValueError):
return False

def __hash__(self):
Expand Down

0 comments on commit 58f4454

Please sign in to comment.