From 228f1c258454d13c1985676c914ba39269cadfb8 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Tue, 23 Oct 2018 22:40:54 +0300 Subject: [PATCH] [2.7] bpo-34794: Fix a leak in Tkinter. (GH-10025) Based on the investigation by Xiang Zhang.. (cherry picked from commit df13df41a25765d8a39a77220691698498e758d4) Co-authored-by: Serhiy Storchaka --- .../next/Library/2018-10-21-14-53-19.bpo-34794.yt3R4-.rst | 2 ++ Modules/_tkinter.c | 6 ++---- 2 files changed, 4 insertions(+), 4 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2018-10-21-14-53-19.bpo-34794.yt3R4-.rst diff --git a/Misc/NEWS.d/next/Library/2018-10-21-14-53-19.bpo-34794.yt3R4-.rst b/Misc/NEWS.d/next/Library/2018-10-21-14-53-19.bpo-34794.yt3R4-.rst new file mode 100644 index 00000000000000..770807fc765365 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2018-10-21-14-53-19.bpo-34794.yt3R4-.rst @@ -0,0 +1,2 @@ +Fixed a leak in Tkinter when pass the Python wrapper around Tcl_Obj back to +Tcl/Tk. diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c index c71ffd016ad881..58640e240f3786 100644 --- a/Modules/_tkinter.c +++ b/Modules/_tkinter.c @@ -1205,10 +1205,8 @@ AsObj(PyObject *value) } #endif - if(PyTclObject_Check(value)) { - Tcl_Obj *v = ((PyTclObject*)value)->value; - Tcl_IncrRefCount(v); - return v; + if (PyTclObject_Check(value)) { + return ((PyTclObject*)value)->value; } {