summaryrefslogtreecommitdiff
path: root/Modules/_tkinter.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/_tkinter.c')
-rw-r--r--Modules/_tkinter.c528
1 files changed, 155 insertions, 373 deletions
diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c
index 70f47036d0..dbb42d637a 100644
--- a/Modules/_tkinter.c
+++ b/Modules/_tkinter.c
@@ -230,7 +230,7 @@ static PyThreadState *tcl_tstate = NULL;
/**** Tkapp Object Declaration ****/
-static PyTypeObject Tkapp_Type;
+static PyObject *Tkapp_Type;
typedef struct {
PyObject_HEAD
@@ -250,7 +250,6 @@ typedef struct {
Tcl_ObjType *StringType;
} TkappObject;
-#define Tkapp_Check(v) (Py_TYPE(v) == &Tkapp_Type)
#define Tkapp_Interp(v) (((TkappObject *) (v))->interp)
#define Tkapp_Result(v) Tcl_GetStringResult(Tkapp_Interp(v))
@@ -323,115 +322,9 @@ WaitForMainloop(TkappObject* self)
#endif /* WITH_THREAD */
-static char *
-AsString(PyObject *value, PyObject *tmp)
-{
- if (PyBytes_Check(value))
- return PyBytes_AsString(value);
- else if (PyUnicode_Check(value)) {
- PyObject *v = PyUnicode_AsUTF8String(value);
- if (v == NULL)
- return NULL;
- if (PyList_Append(tmp, v) != 0) {
- Py_DECREF(v);
- return NULL;
- }
- Py_DECREF(v);
- return PyBytes_AsString(v);
- }
- else {
- PyObject *v = PyObject_Str(value);
- if (v == NULL)
- return NULL;
- if (PyList_Append(tmp, v) != 0) {
- Py_DECREF(v);
- return NULL;
- }
- Py_DECREF(v);
- return PyBytes_AsString(v);
- }
-}
-
-
#define ARGSZ 64
-static char *
-Merge(PyObject *args)
-{
- PyObject *tmp = NULL;
- char *argvStore[ARGSZ];
- char **argv = NULL;
- int fvStore[ARGSZ];
- int *fv = NULL;
- int argc = 0, fvc = 0, i;
- char *res = NULL;
-
- if (!(tmp = PyList_New(0)))
- return NULL;
-
- argv = argvStore;
- fv = fvStore;
-
- if (args == NULL)
- argc = 0;
-
- else if (!PyTuple_Check(args)) {
- argc = 1;
- fv[0] = 0;
- if (!(argv[0] = AsString(args, tmp)))
- goto finally;
- }
- else {
- argc = PyTuple_Size(args);
-
- if (argc > ARGSZ) {
- argv = (char **)ckalloc(argc * sizeof(char *));
- fv = (int *)ckalloc(argc * sizeof(int));
- if (argv == NULL || fv == NULL) {
- PyErr_NoMemory();
- goto finally;
- }
- }
-
- for (i = 0; i < argc; i++) {
- PyObject *v = PyTuple_GetItem(args, i);
- if (PyTuple_Check(v)) {
- fv[i] = 1;
- if (!(argv[i] = Merge(v)))
- goto finally;
- fvc++;
- }
- else if (v == Py_None) {
- argc = i;
- break;
- }
- else {
- fv[i] = 0;
- if (!(argv[i] = AsString(v, tmp)))
- goto finally;
- fvc++;
- }
- }
- }
- res = Tcl_Merge(argc, argv);
- if (res == NULL)
- PyErr_SetString(Tkinter_TclError, "merge failed");
-
- finally:
- for (i = 0; i < fvc; i++)
- if (fv[i]) {
- ckfree(argv[i]);
- }
- if (argv != argvStore)
- ckfree(FREECAST argv);
- if (fv != fvStore)
- ckfree(FREECAST fv);
-
- Py_DECREF(tmp);
- return res;
-}
-
static PyObject *
@@ -442,8 +335,7 @@ Split(char *list)
PyObject *v;
if (list == NULL) {
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
if (Tcl_SplitList((Tcl_Interp *)NULL, list, &argc, &argv) != TCL_OK) {
@@ -594,7 +486,7 @@ Tkapp_New(char *screenName, char *className,
TkappObject *v;
char *argv0;
- v = PyObject_New(TkappObject, &Tkapp_Type);
+ v = PyObject_New(TkappObject, (PyTypeObject *) Tkapp_Type);
if (v == NULL)
return NULL;
@@ -744,14 +636,14 @@ typedef struct {
PyObject *string; /* This cannot cause cycles. */
} PyTclObject;
-static PyTypeObject PyTclObject_Type;
-#define PyTclObject_Check(v) ((v)->ob_type == &PyTclObject_Type)
+static PyObject *PyTclObject_Type;
+#define PyTclObject_Check(v) ((v)->ob_type == (PyTypeObject *) PyTclObject_Type)
static PyObject *
newPyTclObject(Tcl_Obj *arg)
{
PyTclObject *self;
- self = PyObject_New(PyTclObject, &PyTclObject_Type);
+ self = PyObject_New(PyTclObject, (PyTypeObject *) PyTclObject_Type);
if (self == NULL)
return NULL;
Tcl_IncrRefCount(arg);
@@ -885,50 +777,25 @@ static PyGetSetDef PyTclObject_getsetlist[] = {
{0},
};
-static PyTypeObject PyTclObject_Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "_tkinter.Tcl_Obj", /*tp_name*/
- sizeof(PyTclObject), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- /* methods */
- (destructor)PyTclObject_dealloc,/*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_reserved*/
- (reprfunc)PyTclObject_repr, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- (reprfunc)PyTclObject_str, /*tp_str*/
- PyObject_GenericGetAttr, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- 0, /*tp_doc*/
- 0, /*tp_traverse*/
- 0, /*tp_clear*/
- PyTclObject_richcompare, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- 0, /*tp_methods*/
- 0, /*tp_members*/
- PyTclObject_getsetlist, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- 0, /*tp_init*/
- 0, /*tp_alloc*/
- 0, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
+static PyType_Slot PyTclObject_Type_slots[] = {
+ {Py_tp_dealloc, (destructor)PyTclObject_dealloc},
+ {Py_tp_repr, (reprfunc)PyTclObject_repr},
+ {Py_tp_str, (reprfunc)PyTclObject_str},
+ {Py_tp_getattro, NULL},
+ {Py_tp_richcompare, PyTclObject_richcompare},
+ {Py_tp_getset, PyTclObject_getsetlist},
+ {0, 0}
};
+static PyType_Spec PyTclObject_Type_spec = {
+ "_tkinter.Tcl_Obj",
+ sizeof(PyTclObject),
+ 0,
+ Py_TPFLAGS_DEFAULT,
+ PyTclObject_Type_slots,
+};
+
+
static Tcl_Obj*
AsObj(PyObject *value)
{
@@ -1332,42 +1199,6 @@ Tkapp_Call(PyObject *selfptr, PyObject *args)
static PyObject *
-Tkapp_GlobalCall(PyObject *self, PyObject *args)
-{
- /* Could do the same here as for Tkapp_Call(), but this is not used
- much, so I can't be bothered. Unfortunately Tcl doesn't export a
- way for the user to do what all its Global* variants do (save and
- reset the scope pointer, call the local version, restore the saved
- scope pointer). */
-
- char *cmd;
- PyObject *res = NULL;
-
- if (PyErr_WarnEx(PyExc_DeprecationWarning,
- "globalcall is deprecated and will be removed in 3.4",
- 1) < 0)
- return 0;
-
- CHECK_TCL_APPARTMENT;
-
- cmd = Merge(args);
- if (cmd) {
- int err;
- ENTER_TCL
- err = Tcl_GlobalEval(Tkapp_Interp(self), cmd);
- ENTER_OVERLAP
- if (err == TCL_ERROR)
- res = Tkinter_Error(self);
- else
- res = PyUnicode_FromString(Tkapp_Result(self));
- LEAVE_OVERLAP_TCL
- ckfree(cmd);
- }
-
- return res;
-}
-
-static PyObject *
Tkapp_Eval(PyObject *self, PyObject *args)
{
char *script;
@@ -1391,34 +1222,6 @@ Tkapp_Eval(PyObject *self, PyObject *args)
}
static PyObject *
-Tkapp_GlobalEval(PyObject *self, PyObject *args)
-{
- char *script;
- PyObject *res = NULL;
- int err;
-
- if (PyErr_WarnEx(PyExc_DeprecationWarning,
- "globaleval is deprecated and will be removed in 3.4",
- 1) < 0)
- return 0;
-
- if (!PyArg_ParseTuple(args, "s:globaleval", &script))
- return NULL;
-
- CHECK_TCL_APPARTMENT;
-
- ENTER_TCL
- err = Tcl_GlobalEval(Tkapp_Interp(self), script);
- ENTER_OVERLAP
- if (err == TCL_ERROR)
- res = Tkinter_Error(self);
- else
- res = PyUnicode_FromString(Tkapp_Result(self));
- LEAVE_OVERLAP_TCL
- return res;
-}
-
-static PyObject *
Tkapp_EvalFile(PyObject *self, PyObject *args)
{
char *fileName;
@@ -1478,8 +1281,7 @@ Tkapp_AddErrorInfo(PyObject *self, PyObject *args)
Tcl_AddErrorInfo(Tkapp_Interp(self), msg);
LEAVE_TCL
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
@@ -1961,27 +1763,6 @@ Tkapp_Split(PyObject *self, PyObject *args)
return v;
}
-static PyObject *
-Tkapp_Merge(PyObject *self, PyObject *args)
-{
- char *s;
- PyObject *res = NULL;
-
- if (PyErr_WarnEx(PyExc_DeprecationWarning,
- "merge is deprecated and will be removed in 3.4",
- 1) < 0)
- return 0;
-
- s = Merge(args);
-
- if (s) {
- res = PyUnicode_FromString(s);
- ckfree(s);
- }
-
- return res;
-}
-
/** Tcl Command **/
@@ -2167,8 +1948,7 @@ Tkapp_CreateCommand(PyObject *selfptr, PyObject *args)
return NULL;
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
@@ -2209,8 +1989,7 @@ Tkapp_DeleteCommand(PyObject *selfptr, PyObject *args)
PyErr_SetString(Tkinter_TclError, "can't delete Tcl command");
return NULL;
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
@@ -2314,8 +2093,7 @@ Tkapp_CreateFileHandler(PyObject *self, PyObject *args)
ENTER_TCL
Tcl_CreateFileHandler(tfile, mask, FileHandler, (ClientData) data);
LEAVE_TCL
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *
@@ -2339,15 +2117,14 @@ Tkapp_DeleteFileHandler(PyObject *self, PyObject *args)
ENTER_TCL
Tcl_DeleteFileHandler(tfile);
LEAVE_TCL
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
#endif /* HAVE_CREATEFILEHANDLER */
/**** Tktt Object (timer token) ****/
-static PyTypeObject Tktt_Type;
+static PyObject *Tktt_Type;
typedef struct {
PyObject_HEAD
@@ -2372,8 +2149,7 @@ Tktt_DeleteTimerHandler(PyObject *self, PyObject *args)
Py_DECREF(func);
Py_DECREF(v); /* See Tktt_New() */
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyMethodDef Tktt_methods[] =
@@ -2387,7 +2163,7 @@ Tktt_New(PyObject *func)
{
TkttObject *v;
- v = PyObject_New(TkttObject, &Tktt_Type);
+ v = PyObject_New(TkttObject, (PyTypeObject *) Tktt_Type);
if (v == NULL)
return NULL;
@@ -2420,38 +2196,20 @@ Tktt_Repr(PyObject *self)
v->func == NULL ? ", handler deleted" : "");
}
-static PyTypeObject Tktt_Type =
-{
- PyVarObject_HEAD_INIT(NULL, 0)
- "tktimertoken", /*tp_name */
- sizeof(TkttObject), /*tp_basicsize */
- 0, /*tp_itemsize */
- Tktt_Dealloc, /*tp_dealloc */
- 0, /*tp_print */
- 0, /*tp_getattr */
- 0, /*tp_setattr */
- 0, /*tp_reserved */
- Tktt_Repr, /*tp_repr */
- 0, /*tp_as_number */
- 0, /*tp_as_sequence */
- 0, /*tp_as_mapping */
- 0, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- 0, /*tp_doc*/
- 0, /*tp_traverse*/
- 0, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- Tktt_methods, /*tp_methods*/
+static PyType_Slot Tktt_Type_slots[] = {
+ {Py_tp_dealloc, Tktt_Dealloc},
+ {Py_tp_repr, Tktt_Repr},
+ {Py_tp_methods, Tktt_methods},
+ {0, 0}
};
+static PyType_Spec Tktt_Type_spec = {
+ "tktimertoken",
+ sizeof(TkttObject),
+ 0,
+ Py_TPFLAGS_DEFAULT,
+ Tktt_Type_slots,
+};
/** Timer Handler **/
@@ -2573,8 +2331,7 @@ Tkapp_MainLoop(PyObject *selfptr, PyObject *args)
excInCmd = valInCmd = trbInCmd = NULL;
return NULL;
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *
@@ -2600,8 +2357,7 @@ Tkapp_Quit(PyObject *self, PyObject *args)
return NULL;
quitMainLoop = 1;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *
@@ -2658,8 +2414,7 @@ Tkapp_TkInit(PyObject *self, PyObject *args)
return NULL;
}
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *
@@ -2673,8 +2428,7 @@ Tkapp_WantObjects(PyObject *self, PyObject *args)
return PyBool_FromLong(((TkappObject*)self)->wantobjects);
((TkappObject*)self)->wantobjects = wantobjects;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *
@@ -2683,8 +2437,7 @@ Tkapp_WillDispatch(PyObject *self, PyObject *args)
((TkappObject*)self)->dispatching = 1;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
@@ -2695,9 +2448,7 @@ static PyMethodDef Tkapp_methods[] =
{"willdispatch", Tkapp_WillDispatch, METH_NOARGS},
{"wantobjects", Tkapp_WantObjects, METH_VARARGS},
{"call", Tkapp_Call, METH_VARARGS},
- {"globalcall", Tkapp_GlobalCall, METH_VARARGS},
{"eval", Tkapp_Eval, METH_VARARGS},
- {"globaleval", Tkapp_GlobalEval, METH_VARARGS},
{"evalfile", Tkapp_EvalFile, METH_VARARGS},
{"record", Tkapp_Record, METH_VARARGS},
{"adderrorinfo", Tkapp_AddErrorInfo, METH_VARARGS},
@@ -2716,7 +2467,6 @@ static PyMethodDef Tkapp_methods[] =
{"exprboolean", Tkapp_ExprBoolean, METH_VARARGS},
{"splitlist", Tkapp_SplitList, METH_VARARGS},
{"split", Tkapp_Split, METH_VARARGS},
- {"merge", Tkapp_Merge, METH_VARARGS},
{"createcommand", Tkapp_CreateCommand, METH_VARARGS},
{"deletecommand", Tkapp_DeleteCommand, METH_VARARGS},
#ifdef HAVE_CREATEFILEHANDLER
@@ -2747,36 +2497,19 @@ Tkapp_Dealloc(PyObject *self)
DisableEventHook();
}
-static PyTypeObject Tkapp_Type =
-{
- PyVarObject_HEAD_INIT(NULL, 0)
- "tkapp", /*tp_name */
- sizeof(TkappObject), /*tp_basicsize */
- 0, /*tp_itemsize */
- Tkapp_Dealloc, /*tp_dealloc */
- 0, /*tp_print */
- 0, /*tp_getattr */
- 0, /*tp_setattr */
- 0, /*tp_reserved */
- 0, /*tp_repr */
- 0, /*tp_as_number */
- 0, /*tp_as_sequence */
- 0, /*tp_as_mapping */
- 0, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- 0, /*tp_doc*/
- 0, /*tp_traverse*/
- 0, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- Tkapp_methods, /*tp_methods*/
+static PyType_Slot Tkapp_Type_slots[] = {
+ {Py_tp_dealloc, Tkapp_Dealloc},
+ {Py_tp_methods, Tkapp_methods},
+ {0, 0}
+};
+
+
+static PyType_Spec Tkapp_Type_spec = {
+ "tkapp",
+ sizeof(TkappObject),
+ 0,
+ Py_TPFLAGS_DEFAULT,
+ Tkapp_Type_slots,
};
@@ -2932,8 +2665,7 @@ Tkinter_setbusywaitinterval(PyObject *self, PyObject *args)
return NULL;
}
Tkinter_busywaitinterval = new_val;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static char setbusywaitinterval_doc[] =
@@ -3066,27 +2798,6 @@ DisableEventHook(void)
}
-/* all errors will be checked in one fell swoop in init_tkinter() */
-static void
-ins_long(PyObject *d, char *name, long val)
-{
- PyObject *v = PyLong_FromLong(val);
- if (v) {
- PyDict_SetItemString(d, name, v);
- Py_DECREF(v);
- }
-}
-static void
-ins_string(PyObject *d, char *name, char *val)
-{
- PyObject *v = PyUnicode_FromString(val);
- if (v) {
- PyDict_SetItemString(d, name, v);
- Py_DECREF(v);
- }
-}
-
-
static struct PyModuleDef _tkintermodule = {
PyModuleDef_HEAD_INIT,
"_tkinter",
@@ -3102,45 +2813,116 @@ static struct PyModuleDef _tkintermodule = {
PyMODINIT_FUNC
PyInit__tkinter(void)
{
- PyObject *m, *d, *uexe, *cexe;
+ PyObject *m, *uexe, *cexe, *o;
- if (PyType_Ready(&Tkapp_Type) < 0)
- return NULL;
+ /* Due to cross platform compiler issues the slots must be filled
+ * here. It's required for portability to Windows without requiring
+ * C++. See xxxlimited.c*/
+ PyTclObject_Type_slots[3].pfunc = PyObject_GenericGetAttr;
#ifdef WITH_THREAD
tcl_lock = PyThread_allocate_lock();
+ if (tcl_lock == NULL)
+ return NULL;
#endif
m = PyModule_Create(&_tkintermodule);
if (m == NULL)
return NULL;
- d = PyModule_GetDict(m);
- Tkinter_TclError = PyErr_NewException("_tkinter.TclError", NULL, NULL);
- PyDict_SetItemString(d, "TclError", Tkinter_TclError);
+ o = PyErr_NewException("_tkinter.TclError", NULL, NULL);
+ if (o == NULL) {
+ Py_DECREF(m);
+ return NULL;
+ }
+ Py_INCREF(o);
+ if (PyModule_AddObject(m, "TclError", o)) {
+ Py_DECREF(o);
+ Py_DECREF(m);
+ return NULL;
+ }
+ Tkinter_TclError = o;
- ins_long(d, "READABLE", TCL_READABLE);
- ins_long(d, "WRITABLE", TCL_WRITABLE);
- ins_long(d, "EXCEPTION", TCL_EXCEPTION);
- ins_long(d, "WINDOW_EVENTS", TCL_WINDOW_EVENTS);
- ins_long(d, "FILE_EVENTS", TCL_FILE_EVENTS);
- ins_long(d, "TIMER_EVENTS", TCL_TIMER_EVENTS);
- ins_long(d, "IDLE_EVENTS", TCL_IDLE_EVENTS);
- ins_long(d, "ALL_EVENTS", TCL_ALL_EVENTS);
- ins_long(d, "DONT_WAIT", TCL_DONT_WAIT);
- ins_string(d, "TK_VERSION", TK_VERSION);
- ins_string(d, "TCL_VERSION", TCL_VERSION);
+ if (PyModule_AddIntConstant(m, "READABLE", TCL_READABLE)) {
+ Py_DECREF(m);
+ return NULL;
+ }
+ if (PyModule_AddIntConstant(m, "WRITABLE", TCL_WRITABLE)) {
+ Py_DECREF(m);
+ return NULL;
+ }
+ if (PyModule_AddIntConstant(m, "EXCEPTION", TCL_EXCEPTION)) {
+ Py_DECREF(m);
+ return NULL;
+ }
+ if (PyModule_AddIntConstant(m, "WINDOW_EVENTS", TCL_WINDOW_EVENTS)) {
+ Py_DECREF(m);
+ return NULL;
+ }
+ if (PyModule_AddIntConstant(m, "FILE_EVENTS", TCL_FILE_EVENTS)) {
+ Py_DECREF(m);
+ return NULL;
+ }
+ if (PyModule_AddIntConstant(m, "TIMER_EVENTS", TCL_TIMER_EVENTS)) {
+ Py_DECREF(m);
+ return NULL;
+ }
+ if (PyModule_AddIntConstant(m, "IDLE_EVENTS", TCL_IDLE_EVENTS)) {
+ Py_DECREF(m);
+ return NULL;
+ }
+ if (PyModule_AddIntConstant(m, "ALL_EVENTS", TCL_ALL_EVENTS)) {
+ Py_DECREF(m);
+ return NULL;
+ }
+ if (PyModule_AddIntConstant(m, "DONT_WAIT", TCL_DONT_WAIT)) {
+ Py_DECREF(m);
+ return NULL;
+ }
+ if (PyModule_AddStringConstant(m, "TK_VERSION", TK_VERSION)) {
+ Py_DECREF(m);
+ return NULL;
+ }
+ if (PyModule_AddStringConstant(m, "TCL_VERSION", TCL_VERSION)) {
+ Py_DECREF(m);
+ return NULL;
+ }
- PyDict_SetItemString(d, "TkappType", (PyObject *)&Tkapp_Type);
+ o = PyType_FromSpec(&Tkapp_Type_spec);
+ if (o == NULL) {
+ Py_DECREF(m);
+ return NULL;
+ }
+ if (PyModule_AddObject(m, "TkappType", o)) {
+ Py_DECREF(o);
+ Py_DECREF(m);
+ return NULL;
+ }
+ Tkapp_Type = o;
- if (PyType_Ready(&Tktt_Type) < 0) {
+ o = PyType_FromSpec(&Tktt_Type_spec);
+ if (o == NULL) {
+ Py_DECREF(m);
+ return NULL;
+ }
+ if (PyModule_AddObject(m, "TkttType", o)) {
+ Py_DECREF(o);
Py_DECREF(m);
return NULL;
}
- PyDict_SetItemString(d, "TkttType", (PyObject *)&Tktt_Type);
+ Tktt_Type = o;
- Py_TYPE(&PyTclObject_Type) = &PyType_Type;
- PyDict_SetItemString(d, "Tcl_Obj", (PyObject *)&PyTclObject_Type);
+ o = PyType_FromSpec(&PyTclObject_Type_spec);
+ if (o == NULL) {
+ Py_DECREF(m);
+ return NULL;
+ }
+ if (PyModule_AddObject(m, "Tcl_Obj", o)) {
+ Py_DECREF(o);
+ Py_DECREF(m);
+ return NULL;
+ }
+ PyTclObject_Type = o;
#ifdef TK_AQUA
/* Tk_MacOSXSetupTkNotifier must be called before Tcl's subsystems