New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix creation of string arrays from object types #3491
Conversation
PyObject *scalar = PyArray_ToList(data_obj); | ||
if (scalar != NULL) { | ||
PyObject *s = PyObject_Str(scalar); | ||
if (s != NULL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If s
is NULL
, though, don't we need to propagate the exception?
Added PyObject_Str exception handling |
else if (PyArray_Check(data_obj)) { | ||
/* | ||
* Convert data array to list of objects since | ||
* GetArrayParamsFromObject won't iterator over |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"iterator" <- "iterate"
Looks good apart from some style nitpicks. |
if (discover_itemsize(op, *out_ndim, &itemsize) < 0) { | ||
int size_as_string = 0; | ||
if ((*out_dtype)->type_num == NPY_STRING || | ||
(*out_dtype)->type_num == NPY_UNICODE) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indent reversed ;) The logical part should have the extra indent.
The commit messages should have the relevant acronyms.
etc. Might want to compress the commits after this is done. |
Merged. Thanks. |
Fix creation of string arrays from object types
Don't convert unicode string to ascii string before getting byte length. Also, get length of non string type as ascii or unicode depending on output string type.
Don't convert unicode string to ascii string before getting byte length. Also, get length of non string type as ascii or unicode depending on output string type.
Fixes issue #3398