]> granicus.if.org Git - python/commitdiff
Issue #21951: Fixed a crash in Tkinter on AIX when called Tcl command with
authorSerhiy Storchaka <storchaka@gmail.com>
Thu, 11 Sep 2014 07:58:02 +0000 (10:58 +0300)
committerSerhiy Storchaka <storchaka@gmail.com>
Thu, 11 Sep 2014 07:58:02 +0000 (10:58 +0300)
empty string or tuple argument.

On some platforms Tcl memory allocator returns NULL when allocating zero-sized
block of memory.

1  2 
Lib/test/test_tcl.py
Misc/NEWS
Modules/_tkinter.c

index 03b2c10028e46554c964c1b829c8a8f235c3a20a,da8f6299d6bc093f2778cc5efa45a644f9ec2191..d0251aa339c584bd204092c159e5ededc036b836
@@@ -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 Misc/NEWS
Simple merge
index a8e6d9828ce4d0eadc353294977dd6b18433ae43,6d777d3f77d070769a66e4fc6278c58766bdb6df..02fcb818a3fba1d93f9b826e5923fb4ea9d0dd9f
@@@ -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 *));