diff -r 92b292d68104 Lib/test/test_tcl.py --- a/Lib/test/test_tcl.py Mon Sep 08 17:29:02 2014 -0400 +++ b/Lib/test/test_tcl.py Tue Sep 09 17:58:43 2014 +0300 @@ -418,7 +418,6 @@ 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): @@ -446,9 +445,11 @@ check('string') check('string\xbd') check('string\u20ac') + check('') check(b'string', 'string') check(b'string\xe2\x82\xac', 'string\xe2\x82\xac') check(b'string\xbd', 'string\xbd') + check(b'', '') check('str\x00ing') check('str\x00ing\xbd') check('str\x00ing\u20ac') diff -r 92b292d68104 Modules/_tkinter.c --- a/Modules/_tkinter.c Mon Sep 08 17:29:02 2014 -0400 +++ b/Modules/_tkinter.c Tue Sep 09 17:58:43 2014 +0300 @@ -605,7 +605,7 @@ Tcl_SetVar(v->interp, "tcl_interactive", "0", TCL_GLOBAL_ONLY); /* This is used to get the application class for Tk 4.1 and up */ - argv0 = (char*)ckalloc(strlen(className) + 1); + argv0 = (char*)attemptckalloc(strlen(className) + 1); if (!argv0) { PyErr_NoMemory(); Py_DECREF(v); @@ -639,7 +639,7 @@ if (use) len += strlen(use) + sizeof "-use "; - args = (char*)ckalloc(len); + args = (char*)attemptckalloc(len); if (!args) { PyErr_NoMemory(); Py_DECREF(v); @@ -906,13 +906,15 @@ Py_ssize_t size, i; 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, PyTuple_Check(value) ? "tuple is too long" : "list is too long"); return NULL; } - argv = (Tcl_Obj **) ckalloc(((size_t)size) * sizeof(Tcl_Obj *)); + argv = (Tcl_Obj **) attemptckalloc(((size_t)size) * sizeof(Tcl_Obj *)); if(!argv) { PyErr_NoMemory(); return NULL; @@ -936,6 +938,8 @@ inbuf = PyUnicode_DATA(value); size = PyUnicode_GET_LENGTH(value); + if (size == 0) + return Tcl_NewUnicodeObj((const void *)"", 0); if (!CHECK_SIZE(size, sizeof(Tcl_UniChar))) { PyErr_SetString(PyExc_OverflowError, "string is too long"); return NULL; @@ -944,7 +948,7 @@ if (kind == sizeof(Tcl_UniChar)) return Tcl_NewUnicodeObj(inbuf, size); allocsize = ((size_t)size) * sizeof(Tcl_UniChar); - outbuf = (Tcl_UniChar*)ckalloc(allocsize); + outbuf = (Tcl_UniChar*)attemptckalloc(allocsize); /* Else overflow occurred, and we take the next exit */ if (!outbuf) { PyErr_NoMemory(); @@ -1111,7 +1115,7 @@ "list is too long"); return NULL; } - objv = (Tcl_Obj **)ckalloc(((size_t)objc) * sizeof(Tcl_Obj *)); + objv = (Tcl_Obj **)attemptckalloc(((size_t)objc) * sizeof(Tcl_Obj *)); if (objv == NULL) { PyErr_NoMemory(); objc = 0; @@ -1247,7 +1251,7 @@ PyObject *exc_type, *exc_value, *exc_tb; if (!WaitForMainloop(self)) return NULL; - ev = (Tkapp_CallEvent*)ckalloc(sizeof(Tkapp_CallEvent)); + ev = (Tkapp_CallEvent*)attemptckalloc(sizeof(Tkapp_CallEvent)); ev->ev.proc = (Tcl_EventProc*)Tkapp_CallProc; ev->self = self; ev->args = args; @@ -1498,7 +1502,7 @@ if (!WaitForMainloop(self)) return NULL; - ev = (VarEvent*)ckalloc(sizeof(VarEvent)); + ev = (VarEvent*)attemptckalloc(sizeof(VarEvent)); ev->self = selfptr; ev->args = args; @@ -2098,7 +2102,7 @@ #ifdef WITH_THREAD if (self->threaded && self->thread_id != Tcl_GetCurrentThread()) { Tcl_Condition cond = NULL; - CommandEvent *ev = (CommandEvent*)ckalloc(sizeof(CommandEvent)); + CommandEvent *ev = (CommandEvent*)attemptckalloc(sizeof(CommandEvent)); ev->ev.proc = (Tcl_EventProc*)Tkapp_CommandProc; ev->interp = self->interp; ev->create = 1; @@ -2144,7 +2148,7 @@ if (self->threaded && self->thread_id != Tcl_GetCurrentThread()) { Tcl_Condition cond = NULL; CommandEvent *ev; - ev = (CommandEvent*)ckalloc(sizeof(CommandEvent)); + ev = (CommandEvent*)attemptckalloc(sizeof(CommandEvent)); ev->ev.proc = (Tcl_EventProc*)Tkapp_CommandProc; ev->interp = self->interp; ev->create = 0;