Skip to content
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

Merged
merged 2 commits into from Jul 8, 2013

Conversation

jayvius
Copy link
Contributor

@jayvius jayvius commented Jul 1, 2013

Fixes issue #3398

PyObject *scalar = PyArray_ToList(data_obj);
if (scalar != NULL) {
PyObject *s = PyObject_Str(scalar);
if (s != NULL) {
Copy link
Member

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?

@jayvius
Copy link
Contributor Author

jayvius commented Jul 2, 2013

Added PyObject_Str exception handling

else if (PyArray_Check(data_obj)) {
/*
* Convert data array to list of objects since
* GetArrayParamsFromObject won't iterator over
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"iterator" <- "iterate"

@charris
Copy link
Member

charris commented Jul 7, 2013

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) {
Copy link
Member

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.

@charris
Copy link
Member

charris commented Jul 8, 2013

The commit messages should have the relevant acronyms.

STY: -- whitespace, pep8, etc
MAINT: -- refactoring
BUG: -- well, a bug ;)

etc. Might want to compress the commits after this is done.

@charris
Copy link
Member

charris commented Jul 8, 2013

Merged. Thanks.

charris added a commit that referenced this pull request Jul 8, 2013
Fix creation of string arrays from object types
@charris charris merged commit 884c403 into numpy:master Jul 8, 2013
@jayvius jayvius mentioned this pull request Sep 18, 2013
jayvius added a commit to ContinuumIO/numpy that referenced this pull request Sep 18, 2013
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.
charris added a commit that referenced this pull request Sep 19, 2013
charris pushed a commit to charris/numpy that referenced this pull request Sep 19, 2013
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.
charris added a commit that referenced this pull request Sep 19, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants