From: Serhiy Storchaka Date: Thu, 11 Sep 2014 07:58:02 +0000 (+0300) Subject: Issue #21951: Fixed a crash in Tkinter on AIX when called Tcl command with X-Git-Tag: v3.5.0a1~933 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d5fd6188e286a52334e24ef1ce4467618c2c1271;p=thirdparty%2FPython%2Fcpython.git Issue #21951: Fixed a crash in Tkinter on AIX when called Tcl command with empty string or tuple argument. On some platforms Tcl memory allocator returns NULL when allocating zero-sized block of memory. --- d5fd6188e286a52334e24ef1ce4467618c2c1271 diff --cc Lib/test/test_tcl.py index 03b2c10028e4,da8f6299d6bc..d0251aa339c5 --- a/Lib/test/test_tcl.py +++ b/Lib/test/test_tcl.py @@@ -415,10 -415,7 +415,9 @@@ class TclTest(unittest.TestCase) # XXX NaN representation can be not parsable by float() self.assertEqual(passValue((1, '2', (3.4,))), (1, '2', (3.4,)) if self.wantobjects else '1 2 3.4') + self.assertEqual(passValue(['a', ['b', 'c']]), + ('a', ('b', 'c')) if self.wantobjects else 'a {b c}') - @unittest.skipIf(sys.platform.startswith("aix"), 'Issue #21951: crashes on AIX') def test_user_command(self): result = None def testfunc(arg): diff --cc Modules/_tkinter.c index a8e6d9828ce4,6d777d3f77d0..02fcb818a3fb --- a/Modules/_tkinter.c +++ b/Modules/_tkinter.c @@@ -905,11 -898,11 +905,13 @@@ AsObj(PyObject *value Tcl_Obj **argv; Py_ssize_t size, i; - size = PyTuple_Size(value); + size = PySequence_Fast_GET_SIZE(value); + if (size == 0) + return Tcl_NewListObj(0, NULL); if (!CHECK_SIZE(size, sizeof(Tcl_Obj *))) { - PyErr_SetString(PyExc_OverflowError, "tuple is too long"); + PyErr_SetString(PyExc_OverflowError, + PyTuple_Check(value) ? "tuple is too long" : + "list is too long"); return NULL; } argv = (Tcl_Obj **) attemptckalloc(((size_t)size) * sizeof(Tcl_Obj *));