Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BUG: Promotion between strings and objects was assymetric #18152

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

Merged
merged 1 commit into from
Jan 11, 2021

Conversation

seberg
Copy link
Member

@seberg seberg commented Jan 11, 2021

After an unrelated fix, the logic for string and object promotion
was incorrect briefly, this fixes it to be correct (symmetric).
Before, string and unicode would return that
string.__common_dtype(object) is in fact string, which is of
course incorrect. (since object.__common_dtype__(other) always
returns object this depended on the order, and the NumPy tests
apparently did only test the opposite direction (or nothing).

After an unrelated fix, the logic for string and object promotion
was incorrect briefly, this fixes it to be correct (symmetric).
Before, string and unicode would return that
`string.__common_dtype(object)` is in fact `string`, which is of
course incorrect. (since `object.__common_dtype__(other)` always
returns `object` this depended on the order, and the NumPy tests
apparently did only test the opposite direction (or nothing).
@@ -400,9 +400,10 @@ default_builtin_common_dtype(PyArray_DTypeMeta *cls, PyArray_DTypeMeta *other)
static PyArray_DTypeMeta *
string_unicode_common_dtype(PyArray_DTypeMeta *cls, PyArray_DTypeMeta *other)
{
assert(cls->type_num < NPY_NTYPES);
assert(cls->type_num < NPY_NTYPES && cls != other);
Copy link
Member Author

Choose a reason for hiding this comment

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

I am currently guaranteeing this, if that would change UNICODE+UNICODE would misbehave (but that would also lead to very loud errors all over the place).

@seberg
Copy link
Member Author

seberg commented Jan 11, 2021

Hmmm, test failure in:

          out = subprocess.check_output(['nm.exe', '--help'])

because nm was not found, restarted the test probably flaky, just noting in case it happens more often.

@mattip
Copy link
Member

mattip commented Jan 11, 2021

I have been seeing the nm.exe failure about once a week or so.

@charris charris merged commit e745a19 into numpy:master Jan 11, 2021
@charris
Copy link
Member

charris commented Jan 11, 2021

Thanks Sebastian.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants