@@ -122,8 +122,15 @@ def _iinfo(dtype):
122
122
return iinfo
123
123
124
124
125
- _raises_int_overflow = pytest .raises ( # noqa: PDF010
126
- (OverflowError , TypeError , ValueError ), match = None
125
+ _raises_any_integer_cast_exception = pytest .raises ( # noqa: PDF010
126
+ (OverflowError , TypeError , ValueError ),
127
+ match = (
128
+ "(Overflow)|"
129
+ "(Python int too large to convert to C long)|"
130
+ "(cannot safely cast non-equivalent)|"
131
+ "(Integer out of range)|"
132
+ "(Unable to convert column)"
133
+ ),
127
134
)
128
135
129
136
@@ -133,8 +140,8 @@ def _iinfo(dtype):
133
140
[
134
141
(lambda dtype : _iinfo (dtype ).max , nullcontext ()), # in range does not raise
135
142
(lambda dtype : _iinfo (dtype ).min , nullcontext ()), # in range does not raise
136
- (lambda dtype : _iinfo (dtype ).max + 1 , _raises_int_overflow ),
137
- (lambda dtype : _iinfo (dtype ).min - 1 , _raises_int_overflow ),
143
+ (lambda dtype : _iinfo (dtype ).max + 1 , _raises_any_integer_cast_exception ),
144
+ (lambda dtype : _iinfo (dtype ).min - 1 , _raises_any_integer_cast_exception ),
138
145
],
139
146
)
140
147
def test_integer_overflow_with_user_dtype (all_parsers , any_int_dtype , getval , expected ):
@@ -147,7 +154,7 @@ def test_integer_overflow_with_user_dtype(all_parsers, any_int_dtype, getval, ex
147
154
# int8, int16, int32 only throw a FutureWarning until deprecation from #41734
148
155
# becomes enforced. After enforcement, the following block must be deleted.
149
156
if (
150
- (expected is _raises_int_overflow )
157
+ (expected == _raises_any_integer_cast_exception )
151
158
and (parser .engine == "python" )
152
159
and (not is_extension_array_dtype (dtype ))
153
160
and (dtype < np .dtype ("int64" ))
0 commit comments