diff options
author | Pauli Virtanen <pav@iki.fi> | 2010-02-20 18:08:44 +0000 |
---|---|---|
committer | Pauli Virtanen <pav@iki.fi> | 2010-02-20 18:08:44 +0000 |
commit | ff91dbef61f42479cbe46d4ed841a1fef16f4436 (patch) | |
tree | 9b550c1fc6e131ac6a49d59d41e6920fd80a2d53 | |
parent | fc064f18e131cb2bc287c4db8b95ed4a1d129dd3 (diff) | |
download | numpy-ff91dbef61f42479cbe46d4ed841a1fef16f4436.tar.gz |
3K: BUG: do not convert Bytes/Unicode via PEP 3118 buffers -- use 'S/U#' instead
-rw-r--r-- | numpy/core/src/multiarray/ctors.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/numpy/core/src/multiarray/ctors.c b/numpy/core/src/multiarray/ctors.c index 5e8102d59..2a5c2c4e9 100644 --- a/numpy/core/src/multiarray/ctors.c +++ b/numpy/core/src/multiarray/ctors.c @@ -1752,11 +1752,11 @@ PyArray_FromAny(PyObject *op, PyArray_Descr *newtype, int min_depth, } r = Array_FromPyScalar(op, newtype); } -#if PY_VERSION_HEX >= 0x02070000 - else if (_array_from_buffer_3118(op, &r) == 0) { + else if (!PyBytes_Check(op) && !PyUnicode_Check(op) && + _array_from_buffer_3118(op, &r) == 0) { + /* PEP 3118 buffer -- but don't accept Bytes objects here */ r = r; } -#endif else if (PyArray_HasArrayInterfaceType(op, newtype, context, r)) { PyObject *new; if (r == NULL) { @@ -3231,8 +3231,6 @@ PyArray_FromBuffer(PyObject *buf, PyArray_Descr *type, Py_INCREF(buf); } -#warning XXX: Should implement support for the new buffer interface here! - if (PyObject_AsWriteBuffer(buf, (void *)&data, &ts) == -1) { write = 0; PyErr_Clear(); |