@@ -5396,6 +5396,8 @@ ufunc_outer(PyUFuncObject *ufunc, PyObject *args, PyObject *kwds)
5396
5396
PyArrayObject * ap1 = NULL , * ap2 = NULL , * ap_new = NULL ;
5397
5397
PyObject * new_args , * tmp ;
5398
5398
PyObject * shape1 , * shape2 , * newshape ;
5399
+ static PyObject * _numpy_matrix ;
5400
+
5399
5401
5400
5402
errval = PyUFunc_CheckOverride (ufunc , "outer" , args , kwds , & override );
5401
5403
if (errval ) {
@@ -5428,7 +5430,18 @@ ufunc_outer(PyUFuncObject *ufunc, PyObject *args, PyObject *kwds)
5428
5430
if (tmp == NULL ) {
5429
5431
return NULL ;
5430
5432
}
5431
- ap1 = (PyArrayObject * ) PyArray_FromObject (tmp , NPY_NOTYPE , 0 , 0 );
5433
+
5434
+ npy_cache_import (
5435
+ "numpy" ,
5436
+ "matrix" ,
5437
+ & _numpy_matrix );
5438
+
5439
+ if (PyObject_IsInstance (tmp , _numpy_matrix )) {
5440
+ ap1 = (PyArrayObject * ) PyArray_FromObject (tmp , NPY_NOTYPE , 0 , 0 );
5441
+ }
5442
+ else {
5443
+ ap1 = (PyArrayObject * ) PyArray_FROM_O (tmp );
5444
+ }
5432
5445
Py_DECREF (tmp );
5433
5446
if (ap1 == NULL ) {
5434
5447
return NULL ;
@@ -5437,7 +5450,12 @@ ufunc_outer(PyUFuncObject *ufunc, PyObject *args, PyObject *kwds)
5437
5450
if (tmp == NULL ) {
5438
5451
return NULL ;
5439
5452
}
5440
- ap2 = (PyArrayObject * )PyArray_FromObject (tmp , NPY_NOTYPE , 0 , 0 );
5453
+ if (PyObject_IsInstance (tmp , _numpy_matrix )) {
5454
+ ap2 = (PyArrayObject * ) PyArray_FromObject (tmp , NPY_NOTYPE , 0 , 0 );
5455
+ }
5456
+ else {
5457
+ ap2 = (PyArrayObject * ) PyArray_FROM_O (tmp );
5458
+ }
5441
5459
Py_DECREF (tmp );
5442
5460
if (ap2 == NULL ) {
5443
5461
Py_DECREF (ap1 );
0 commit comments