Issue #7142: Fix uses of unicode in memoryview objects
This commit is contained in:
parent
196b0925ca
commit
08133af12e
|
@ -54,6 +54,12 @@ class AbstractMemoryTests:
|
|||
m = self._view(b)
|
||||
self.assertEqual(list(m), [m[i] for i in range(len(m))])
|
||||
|
||||
def test_repr(self):
|
||||
for tp in self._types:
|
||||
b = tp(self._source)
|
||||
m = self._view(b)
|
||||
self.assertIsInstance(m.__repr__(), str)
|
||||
|
||||
def test_setitem_readonly(self):
|
||||
if not self.ro_type:
|
||||
return
|
||||
|
@ -156,6 +162,7 @@ class AbstractMemoryTests:
|
|||
def check_attributes_with_type(self, tp):
|
||||
m = self._view(tp(self._source))
|
||||
self.assertEquals(m.format, self.format)
|
||||
self.assertIsInstance(m.format, str)
|
||||
self.assertEquals(m.itemsize, self.itemsize)
|
||||
self.assertEquals(m.ndim, 1)
|
||||
self.assertEquals(m.shape, (6,))
|
||||
|
|
|
@ -335,7 +335,7 @@ PyMemoryView_GetContiguous(PyObject *obj, int buffertype, char fort)
|
|||
static PyObject *
|
||||
memory_format_get(PyMemoryViewObject *self)
|
||||
{
|
||||
return PyUnicode_FromString(self->view.format);
|
||||
return PyString_FromString(self->view.format);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
@ -503,7 +503,7 @@ memory_dealloc(PyMemoryViewObject *self)
|
|||
static PyObject *
|
||||
memory_repr(PyMemoryViewObject *self)
|
||||
{
|
||||
return PyUnicode_FromFormat("<memory at %p>", self);
|
||||
return PyString_FromFormat("<memory at %p>", self);
|
||||
}
|
||||
|
||||
/* Sequence methods */
|
||||
|
|
Loading…
Reference in New Issue