diff options
Diffstat (limited to 'numpy/core')
-rw-r--r-- | numpy/core/src/multiarray/convert_datatype.c | 3 | ||||
-rw-r--r-- | numpy/core/src/multiarray/textreading/tokenize.cpp | 5 |
2 files changed, 6 insertions, 2 deletions
diff --git a/numpy/core/src/multiarray/convert_datatype.c b/numpy/core/src/multiarray/convert_datatype.c index 79f918d2a..8d0a4cd56 100644 --- a/numpy/core/src/multiarray/convert_datatype.c +++ b/numpy/core/src/multiarray/convert_datatype.c @@ -3403,6 +3403,9 @@ void_to_void_resolve_descriptors( /* From structured to structured, need to check fields */ casting = can_cast_fields_safety( given_descrs[0], given_descrs[1], view_offset); + if (casting < 0) { + return -1; + } } else if (given_descrs[0]->names != NULL) { return structured_to_nonstructured_resolve_descriptors( diff --git a/numpy/core/src/multiarray/textreading/tokenize.cpp b/numpy/core/src/multiarray/textreading/tokenize.cpp index b09fc3356..d0d9cf844 100644 --- a/numpy/core/src/multiarray/textreading/tokenize.cpp +++ b/numpy/core/src/multiarray/textreading/tokenize.cpp @@ -386,9 +386,10 @@ tokenize(stream *s, tokenizer_state *ts, parser_config *const config) * empty. * 2. If we are splitting on whitespace we always ignore a last empty * field to match Python's splitting: `" 1 ".split()`. + * (Zero fields are possible when we are only skipping lines) */ - if (ts->num_fields == 1 - || ts->unquoted_state == TOKENIZE_UNQUOTED_WHITESPACE) { + if (ts->num_fields == 1 || (ts->num_fields > 0 + && ts->unquoted_state == TOKENIZE_UNQUOTED_WHITESPACE)) { size_t offset_last = ts->fields[ts->num_fields-1].offset; size_t end_last = ts->fields[ts->num_fields].offset; if (!ts->fields->quoted && end_last - offset_last == 1) { |