diff options
-rw-r--r-- | numpy/core/src/umath/ufunc_object.c | 6 | ||||
-rw-r--r-- | numpy/core/src/umath/umath_tests.c.src | 6 | ||||
-rw-r--r-- | numpy/core/tests/test_ufunc.py | 4 |
3 files changed, 14 insertions, 2 deletions
diff --git a/numpy/core/src/umath/ufunc_object.c b/numpy/core/src/umath/ufunc_object.c index 950914b4e..b871061b3 100644 --- a/numpy/core/src/umath/ufunc_object.c +++ b/numpy/core/src/umath/ufunc_object.c @@ -5596,8 +5596,10 @@ ufunc_get_doc(PyUFuncObject *ufunc) if (doc == NULL) { return NULL; } - PyUString_ConcatAndDel(&doc, - PyUString_FromFormat("\n\n%s", ufunc->doc)); + if (ufunc->doc != NULL) { + PyUString_ConcatAndDel(&doc, + PyUString_FromFormat("\n\n%s", ufunc->doc)); + } return doc; } diff --git a/numpy/core/src/umath/umath_tests.c.src b/numpy/core/src/umath/umath_tests.c.src index 6cd181897..8d9009a1a 100644 --- a/numpy/core/src/umath/umath_tests.c.src +++ b/numpy/core/src/umath/umath_tests.c.src @@ -305,6 +305,12 @@ addUfuncs(PyObject *dictionary) { 0, euclidean_pdist_signature); PyDict_SetItemString(dictionary, "euclidean_pdist", f); Py_DECREF(f); + f = PyUFunc_FromFuncAndDataAndSignature(inner1d_functions, inner1d_data, + inner1d_signatures, 2, 2, 1, PyUFunc_None, "inner1d_no_doc", + NULL, + 0, inner1d_signature); + PyDict_SetItemString(dictionary, "inner1d_no_doc", f); + Py_DECREF(f); } diff --git a/numpy/core/tests/test_ufunc.py b/numpy/core/tests/test_ufunc.py index 3d6251253..547cc495b 100644 --- a/numpy/core/tests/test_ufunc.py +++ b/numpy/core/tests/test_ufunc.py @@ -1283,6 +1283,10 @@ class TestUfunc(TestCase): assert_equal(y_base[1,:], y_base_copy[1,:]) assert_equal(y_base[3,:], y_base_copy[3,:]) + def test_no_doc_string(self): + # gh-9337 + assert_('\n' not in umt.inner1d_no_doc.__doc__) + if __name__ == "__main__": run_module_suite() |