summaryrefslogtreecommitdiff
path: root/numpy/core/src
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2021-01-11 15:15:16 -0700
committerGitHub <noreply@github.com>2021-01-11 15:15:16 -0700
commite745a19cb0ea9af0fd252a4625ec793130f87414 (patch)
tree70afc2262b3d4afba46ea6220012cc131564f279 /numpy/core/src
parentd0f19a2d633b12119909b7c9205a8c8932ebbd51 (diff)
parentc9e8bc8ac5d804d0acba1f6e81a4bb9c32984d84 (diff)
downloadnumpy-e745a19cb0ea9af0fd252a4625ec793130f87414.tar.gz
Merge pull request #18152 from seberg/fix-string-object-promotion
BUG: Promotion between strings and objects was assymetric
Diffstat (limited to 'numpy/core/src')
-rw-r--r--numpy/core/src/multiarray/dtypemeta.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/numpy/core/src/multiarray/dtypemeta.c b/numpy/core/src/multiarray/dtypemeta.c
index b1cd074a0..2931977c2 100644
--- a/numpy/core/src/multiarray/dtypemeta.c
+++ b/numpy/core/src/multiarray/dtypemeta.c
@@ -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);
if (!other->legacy || (!PyTypeNum_ISNUMBER(other->type_num) &&
- (cls->type_num == NPY_STRING && other->type_num == NPY_UNICODE))) {
+ /* Not numeric so defer unless cls is unicode and other is string */
+ !(cls->type_num == NPY_UNICODE && other->type_num == NPY_STRING))) {
Py_INCREF(Py_NotImplemented);
return (PyArray_DTypeMeta *)Py_NotImplemented;
}