-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
gh-116946: fully implement GC protocol for _tkinter.Tk{app,tt}Object
#138331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
84f832f
a9c01ef
dbb343f
9eb9f47
8e80641
833a85e
022d71e
168fe43
5e5f698
35915b0
ba9c809
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -589,10 +589,14 @@ Tkapp_New(const char *screenName, const char *className, | |||||||||||
int interactive, int wantobjects, int wantTk, int sync, | ||||||||||||
const char *use) | ||||||||||||
{ | ||||||||||||
PyTypeObject *type; | ||||||||||||
TkappObject *v; | ||||||||||||
char *argv0; | ||||||||||||
|
||||||||||||
v = PyObject_New(TkappObject, (PyTypeObject *) Tkapp_Type); | ||||||||||||
type = (PyTypeObject *)Tkapp_Type; | ||||||||||||
assert(type != NULL); | ||||||||||||
assert(type->tp_alloc != NULL); | ||||||||||||
v = (TkappObject *)type->tp_alloc(type, 0); | ||||||||||||
picnixz marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||
if (v == NULL) | ||||||||||||
return NULL; | ||||||||||||
|
||||||||||||
|
@@ -906,11 +910,14 @@ static PyType_Slot PyTclObject_Type_slots[] = { | |||||||||||
}; | ||||||||||||
|
||||||||||||
static PyType_Spec PyTclObject_Type_spec = { | ||||||||||||
"_tkinter.Tcl_Obj", | ||||||||||||
sizeof(PyTclObject), | ||||||||||||
0, | ||||||||||||
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_DISALLOW_INSTANTIATION, | ||||||||||||
PyTclObject_Type_slots, | ||||||||||||
.name = "_tkinter.Tcl_Obj", | ||||||||||||
.basicsize = sizeof(PyTclObject), | ||||||||||||
.flags = ( | ||||||||||||
Py_TPFLAGS_DEFAULT | ||||||||||||
| Py_TPFLAGS_DISALLOW_INSTANTIATION | ||||||||||||
picnixz marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||
| Py_TPFLAGS_IMMUTABLETYPE | ||||||||||||
picnixz marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||
), | ||||||||||||
.slots = PyTclObject_Type_slots, | ||||||||||||
}; | ||||||||||||
|
||||||||||||
|
||||||||||||
|
@@ -2742,9 +2749,13 @@ _tkinter_tktimertoken_deletetimerhandler_impl(TkttObject *self) | |||||||||||
static TkttObject * | ||||||||||||
Tktt_New(PyObject *func) | ||||||||||||
{ | ||||||||||||
PyTypeObject *type; | ||||||||||||
TkttObject *v; | ||||||||||||
|
||||||||||||
v = PyObject_New(TkttObject, (PyTypeObject *) Tktt_Type); | ||||||||||||
type = (PyTypeObject *)Tktt_Type; | ||||||||||||
assert(type != NULL); | ||||||||||||
assert(type->tp_alloc != NULL); | ||||||||||||
v = (TkttObject *)type->tp_alloc(type, 0); | ||||||||||||
|
type = (PyTypeObject *)Tktt_Type; | |
assert(type != NULL); | |
assert(type->tp_alloc != NULL); | |
v = (TkttObject *)type->tp_alloc(type, 0); | |
v = (TkttObject *)((PyTypeObject *)Tktt_Type)->tp_alloc(type, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, we would need
(TkttObject *)((PyTypeObject *)Tktt_Type)->tp_alloc((PyTypeObject *)Tktt_Type, 0);
which is a bit unreadable IMO. So I'll keep the temporary type variable. I would prefer having a macro for calling tp_alloc
because it becomes quite annoying if we need to cast to PyTypeObject* everytime twice.
#define _PyObject_New(T, type) \
((T *)((PyTypeObject *)type)->tp_alloc((PyTypeObject *)type, 0))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to move the variable definition aside to their first assignment:
Same below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I followed the existing style. Do you want me to move the
char *arg
as well?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you want. You can leave argv0 as it is to keep the diff small.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I would be more comfortable not changing the style of this function. It's a long function, and if we were to use gotos instead for some refactoring, we could benefit for having everything declared at the top. Do you mind I leave it as is?