diff options
author | Matti Picus <matti.picus@gmail.com> | 2021-12-16 00:37:22 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-16 00:37:22 -0700 |
commit | 1eb2f2e8e05b4b479a1a6b3d1e617be48eb175f9 (patch) | |
tree | df148a8cbfdb5ab610f369e61524c6265a4ea05b | |
parent | 06e37a3e6e48f06a3ff4010b4ad88e4b001184fb (diff) | |
parent | 6c5a9ac9681dba754728d40e3d2ea0fe4c10abcc (diff) | |
download | numpy-1eb2f2e8e05b4b479a1a6b3d1e617be48eb175f9.tar.gz |
Merge pull request #20593 from seberg/check-for-buffer
MAINT: Check for buffer interface support rather than try/except
-rw-r--r-- | numpy/core/src/multiarray/ctors.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/numpy/core/src/multiarray/ctors.c b/numpy/core/src/multiarray/ctors.c index 5ece33e8c..e22708f39 100644 --- a/numpy/core/src/multiarray/ctors.c +++ b/numpy/core/src/multiarray/ctors.c @@ -1301,9 +1301,10 @@ _array_from_array_like(PyObject *op, * We skip bytes and unicode since they are considered scalars. Unicode * would fail but bytes would be incorrectly converted to a uint8 array. */ - if (!PyBytes_Check(op) && !PyUnicode_Check(op)) { + if (PyObject_CheckBuffer(op) && !PyBytes_Check(op) && !PyUnicode_Check(op)) { PyObject *memoryview = PyMemoryView_FromObject(op); if (memoryview == NULL) { + /* TODO: Should probably not blanket ignore errors. */ PyErr_Clear(); } else { |