Skip to content

Commit 40983dd

Browse files
committed
fix: ignore overflow error if encounter invalid char
1 parent 69c35ee commit 40983dd

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pandas/_libs/src/parser/tokenizer.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1907,7 +1907,9 @@ int64_t str_to_int64(const char *p_item, int *error, char tsep) {
19071907
int64_t number = strtoll(p, &endptr, 10);
19081908

19091909
if (errno == ERANGE) {
1910-
*error = ERROR_OVERFLOW;
1910+
// Python's integers can handle pure overflow errors,
1911+
// but for invalid characters, try using different conversion methods.
1912+
*error = *endptr ? ERROR_INVALID_CHARS : ERROR_OVERFLOW;
19111913
errno = 0;
19121914
return 0;
19131915
}
@@ -1967,7 +1969,9 @@ uint64_t str_to_uint64(uint_state *state, const char *p_item, int *error,
19671969
uint64_t number = strtoull(p, &endptr, 10);
19681970

19691971
if (errno == ERANGE) {
1970-
*error = ERROR_OVERFLOW;
1972+
// Python's integers can handle pure overflow errors,
1973+
// but for invalid characters, try using different conversion methods.
1974+
*error = *endptr ? ERROR_INVALID_CHARS : ERROR_OVERFLOW;
19711975
errno = 0;
19721976
return 0;
19731977
}

0 commit comments

Comments
 (0)