summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorStefan Krah <skrah@bytereef.org>2015-11-10 17:18:07 (GMT)
committerStefan Krah <skrah@bytereef.org>2015-11-10 17:18:07 (GMT)
commit3407cc26cb75db535fd0203ad30707e9e92c1957 (patch)
tree2ad951b6cc330f643c3a20c76ae7a774b9d2d51c /Objects
parentfa02131adbf70971ecc07dc349ba64713bdbfe44 (diff)
parent0ce5b6e2688ddf342780b663a095b3e0c9f5cc72 (diff)
downloadcpython-3407cc26cb75db535fd0203ad30707e9e92c1957.zip
cpython-3407cc26cb75db535fd0203ad30707e9e92c1957.tar.gz
cpython-3407cc26cb75db535fd0203ad30707e9e92c1957.tar.bz2
Merge 3.5.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/memoryobject.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c
index 74cad7d..fe54366 100644
--- a/Objects/memoryobject.c
+++ b/Objects/memoryobject.c
@@ -2156,8 +2156,23 @@ static PyObject *
memory_hex(PyMemoryViewObject *self, PyObject *dummy)
{
Py_buffer *src = VIEW_ADDR(self);
+ PyObject *bytes;
+ PyObject *ret;
+
CHECK_RELEASED(self);
- return _Py_strhex(src->buf, src->len);
+
+ if (MV_C_CONTIGUOUS(self->flags)) {
+ return _Py_strhex(src->buf, src->len);
+ }
+
+ bytes = memory_tobytes(self, dummy);
+ if (bytes == NULL)
+ return NULL;
+
+ ret = _Py_strhex(PyBytes_AS_STRING(bytes), Py_SIZE(bytes));
+ Py_DECREF(bytes);
+
+ return ret;
}
static PyObject *