Index: Misc/NEWS =================================================================== --- Misc/NEWS (revision 43417) +++ Misc/NEWS (working copy) @@ -25,6 +25,8 @@ Extension Modules ----------------- +- Fix bug #1454485, crash when passing short strings to unicode arrays. + - Ubuntu bug #29289: Fixed a bug that the gb18030 codec raises RuntimeError on encoding surrogate pair area on UCS4 build. Index: Lib/test/test_array.py =================================================================== --- Lib/test/test_array.py (revision 43417) +++ Lib/test/test_array.py (working copy) @@ -732,6 +732,14 @@ self.assertRaises(TypeError, a.fromunicode) + def test_unicode_buffers(self): + whole = "bar\304\261\305\237" + for i in range(len(whole), 0, -1): + part = whole[:i] + a = array.array('u') + a.append(part) + print a.tounicode() + tests.append(UnicodeTest) class NumberTest(BaseTest): Index: Objects/unicodeobject.c =================================================================== --- Objects/unicodeobject.c (revision 43417) +++ Objects/unicodeobject.c (working copy) @@ -319,7 +319,7 @@ /* Single character Unicode objects in the Latin-1 range are shared when using this constructor */ - if (size == 1 && *u < 256) { + if (size == 1 && (unsigned) *u < 256) { unicode = unicode_latin1[*u]; if (!unicode) { unicode = _PyUnicode_New(1);