]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fixed the array module in unicode disabled build (regression of issue20014).
authorSerhiy Storchaka <storchaka@gmail.com>
Sun, 31 May 2015 08:56:48 +0000 (11:56 +0300)
committerSerhiy Storchaka <storchaka@gmail.com>
Sun, 31 May 2015 08:56:48 +0000 (11:56 +0300)
Lib/test/test_array.py
Modules/arraymodule.c

index 7256b9489c4234d1e30e1bada36f9d992d80e8d2..105cf73946401a41b0d961e6dc2234796c39184a 100644 (file)
@@ -18,7 +18,9 @@ class ArraySubclassWithKwargs(array.array):
         array.array.__init__(self, typecode)
 
 tests = [] # list to accumulate all tests
-typecodes = "cubBhHiIlLfd"
+typecodes = "cbBhHiIlLfd"
+if test_support.have_unicode:
+    typecodes += "u"
 
 class BadConstructorTest(unittest.TestCase):
 
@@ -837,6 +839,7 @@ class CharacterTest(StringTest):
         self.assertEqual(s.color, "red")
         self.assertEqual(s.__dict__.keys(), ["color"])
 
+    @test_support.requires_unicode
     def test_nounicode(self):
         a = array.array(self.typecode, self.example)
         self.assertRaises(ValueError, a.fromunicode, unicode(''))
index c37644d45c6e0099bb3a6af877e8ed7704039d3e..3ed8a33ad7649316895fd65ae3b327607a0d9ae9 100644 (file)
@@ -1940,8 +1940,10 @@ array_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
 
     if (PyString_Check(typecode) && PyString_GET_SIZE(typecode) == 1)
         c = (unsigned char)*PyString_AS_STRING(typecode);
+#ifdef Py_USING_UNICODE
     else if (PyUnicode_Check(typecode) && PyUnicode_GET_SIZE(typecode) == 1)
         c = *PyUnicode_AS_UNICODE(typecode);
+#endif
     else {
         PyErr_Format(PyExc_TypeError,
                      "array() argument 1 or typecode must be char (string or "