diff --git "a/C:\\source\\Python-2.7.10-old/Lib/test/test_array.py" "b/C:\\source\\Python-2.7.10/Lib/test/test_array.py" index b933cbf..c2a409b 100644 --- "a/C:\\source\\Python-2.7.10-old/Lib/test/test_array.py" +++ "b/C:\\source\\Python-2.7.10/Lib/test/test_array.py" @@ -235,6 +235,7 @@ class BaseTest(unittest.TestCase): self.assertRaises(TypeError, a.tostring, 42) self.assertRaises(TypeError, b.fromstring) self.assertRaises(TypeError, b.fromstring, 42) + self.assertRaises(ValueError, a.fromstring, a) b.fromstring(a.tostring()) self.assertEqual(a, b) if a.itemsize>1: diff --git "a/C:\\source\\Python-2.7.10-old/Modules/arraymodule.c" "b/C:\\source\\Python-2.7.10/Modules/arraymodule.c" index 5a92862..ad46fb8 100644 --- "a/C:\\source\\Python-2.7.10-old/Modules/arraymodule.c" +++ "b/C:\\source\\Python-2.7.10/Modules/arraymodule.c" @@ -1380,6 +1380,11 @@ array_fromstring(arrayobject *self, PyObject *args) int itemsize = self->ob_descr->itemsize; if (!PyArg_ParseTuple(args, "s#:fromstring", &str, &n)) return NULL; + if (str == self->ob_item) { + PyErr_SetString(PyExc_ValueError, + "array.fromstring(x): x cannot be self"); + return NULL; + } if (n % itemsize != 0) { PyErr_SetString(PyExc_ValueError, "string length not a multiple of item size");