@@ -76,6 +76,8 @@ cdef extern from "parser/tokenizer.h":
76
76
EAT_COMMENT
77
77
FINISHED
78
78
79
+ enum : ERROR_OVERFLOW
80
+
79
81
ctypedef void * (* io_callback)(void * src, size_t nbytes, size_t * bytes_read,
80
82
int * status)
81
83
ctypedef int (* io_cleanup)(void * src)
@@ -840,9 +842,13 @@ cdef class TextReader:
840
842
else :
841
843
col_res = None
842
844
for dt in dtype_cast_order:
843
- col_res, na_count = self ._convert_with_dtype(dt, i, start,
844
- end, na_filter,
845
- na_hashset)
845
+ try :
846
+ col_res, na_count = self ._convert_with_dtype(
847
+ dt, i, start, end, na_filter, na_hashset)
848
+ except OverflowError :
849
+ col_res, na_count = self ._convert_with_dtype(
850
+ ' |O8' , i, start, end, na_filter, na_hashset)
851
+
846
852
if col_res is not None :
847
853
break
848
854
@@ -966,6 +972,11 @@ cdef class TextReader:
966
972
class CParserError (Exception ):
967
973
pass
968
974
975
+
976
+ class OverflowError (ValueError ):
977
+ pass
978
+
979
+
969
980
def _ensure_encoded (list lst ):
970
981
cdef list result = []
971
982
for x in lst:
@@ -1251,6 +1262,7 @@ cdef _try_double(parser_t *parser, int col, int line_start, int line_end,
1251
1262
1252
1263
return result, na_count
1253
1264
1265
+
1254
1266
cdef _try_int64(parser_t * parser, int col, int line_start, int line_end,
1255
1267
bint na_filter, kh_str_t * na_hashset):
1256
1268
cdef:
@@ -1283,13 +1295,18 @@ cdef _try_int64(parser_t *parser, int col, int line_start, int line_end,
1283
1295
data[i] = str_to_int64(word, INT64_MIN, INT64_MAX,
1284
1296
& error, parser.thousands)
1285
1297
if error != 0 :
1298
+ if error == ERROR_OVERFLOW:
1299
+ raise OverflowError (word)
1300
+
1286
1301
return None , None
1287
1302
else :
1288
1303
for i in range (lines):
1289
1304
word = COLITER_NEXT(it)
1290
1305
data[i] = str_to_int64(word, INT64_MIN, INT64_MAX,
1291
1306
& error, parser.thousands)
1292
1307
if error != 0 :
1308
+ if error == ERROR_OVERFLOW:
1309
+ raise OverflowError (word)
1293
1310
return None , None
1294
1311
1295
1312
return result, na_count
0 commit comments