[Python-checkins] cpython (2.7): Fixed the array module in unicode disabled build (regression of issue20014).
serhiy.storchaka
python-checkins at python.org
Sun May 31 10:57:28 CEST 2015
https://hg.python.org/cpython/rev/6ee122fac1e8
changeset: 96421:6ee122fac1e8
branch: 2.7
parent: 96418:de0ccaaf2e64
user: Serhiy Storchaka <storchaka at gmail.com>
date: Sun May 31 11:56:48 2015 +0300
summary:
Fixed the array module in unicode disabled build (regression of issue20014).
files:
Lib/test/test_array.py | 5 ++++-
Modules/arraymodule.c | 2 ++
2 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/Lib/test/test_array.py b/Lib/test/test_array.py
--- a/Lib/test/test_array.py
+++ b/Lib/test/test_array.py
@@ -18,7 +18,9 @@
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 @@
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(''))
diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c
--- a/Modules/arraymodule.c
+++ b/Modules/arraymodule.c
@@ -1940,8 +1940,10 @@
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 "
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list